Why Java Needs Hierarchical Data

  • 1,703 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,703
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • Relax, Breath, Smile Briefly introduce yourself, what you’re going to talk about, and when it’s appropriate to ask questions. Talk about your dev background
  • FIRST summarize your talk: Created extensions to Java for hierarchical data Even though we’re talking about specific tool today that you may never use, you should still find value in this talk: Also talk about how to better use Hierarchical Data in your apps. Even if you never use Hierarchy, these are concepts you can still use in your own development.
  • (don’t advance text yet) Hierarchy is a compiler that extends Java. Hierarchy compiles code written in the extended Java syntax we created. (show code) This is an embedded Java file with a special extension. Mjava Simple way to think of it is we’ve the Java language much bigger Hierarchy is not really a compiler It’s translator similar to Perl Actually, more like CoffeeScript and actually does the same thing that Eclipse Xtend does…
  • And, not to confuse you, but even though Hierarchy is a translator, we call it a metacompiler Explain why We’ll refer to Hierarchy as a Metacompiler from now on.
  • Hierarchical Data – is very similar to XML In fact, most XML file types have Hierarchy equivalents XML file types (QUESTIONS?) (NEXT SLIDE INTRO) At this point, the easiest way to show you how hierarchy works is to go through a simple example Willie’s Petstore, running example from website.
  • Go over the home page NEXT SLIDE Next, let’s create a matrix file with the news events stored in it.
  • Point out how the web page news items correspond to the elements in the matrix. (LET PEOPLE LOOK OVER CODE AND HANDOUT)
  • Identify parts! Besides small syntax changes, can anyone see any differences between .matrix file and .xml files? Describe differences between .matrix and xml. NO ATTRIBUTE FIELD NAMES Can use Java So how do we know which field a value is in? Using Hierarchy, you Must have a schema defined! Schema defines what field each value has in a field set. Done by position
  • Describe the schema Point out how the position of the field definitions define what field it is in the matrix. So, since StoryDate is the first field defined for the fieldset in the schema, that means it is the first field in the fieldset in the matrix. (Take a look at your hand out of the mapping of fields) Notice is the position of a Descriptor Definition determines the descriptor’s position when used in a matrix. Also notice that field types are Strongly Typed. Allow primitives, so fieldsets are very small and high performance. They could just take the Java Object (QUESTIONS?) (NEXT SLIDE) Nearly done with the first part of this quick tutorial on how hierarchy works. The last thing to look at is how we use the matrix we created in a special Java file. We’ll print out print out the news items to the console
  • Describe the schema Point out how the position of the field definitions define what field it is in the matrix. So, since StoryDate is the first field defined for the fieldset in the schema, that means it is the first field in the fieldset in the matrix. (Take a look at your hand out of the mapping of fields) Notice is the position of a Descriptor Definition determines the descriptor’s position when used in a matrix. Also notice that field types are Strongly Typed. Allow primitives, so fieldsets are very small and high performance. They could just take the Java Object (QUESTIONS?) (NEXT SLIDE) Nearly done with the first part of this quick tutorial on how hierarchy works. The last thing to look at is how we use the matrix we created in a special Java file. We’ll print out print out the news items to the console
  • Has .mjava extension This embedded Java file looks like a regular Java file except for it has extra instructions for accessing matrices Go over them Note, even though called “embedded” file, it’s not like the old SQL pre-processors that did simple text replacement…
  • (QUESTIONS?)
  • Takes much less time to create Hierarchical Data in Hierarchy compared to JAXB (explain) Metacompiler catches your mistakes! Start using Hierarchical Data in ways you never would have before
  • JSON is: Provides extension to Javascript for creation of Simple Data structures For those that are unfamiliar, it’s an xml-like technology for Javascript JS programmers not just use it for exchanging data, but use it to organize their entire code, putting all the major settings and content for code in JSON objects
  • LINQ is: adds native data querying capabilities to .NET languages Based on SQL Really centered around querying
  • [Technology with lots of Potential] Same, simple, flexible data structure as JSON But, also makes it easy to work with Database data and other datasources. We’ll talk about more of the benefits later, but I hope you see, this technology has hit somewhat of a sweet spot, combining the best of both and has the potential to have even a greater impact than either of these two.
  • Describe the parts of this matrix Describe benefits of UDD Much easier to maintain. You don’t have to search the sys to find all the different usages. Becomes a map to all the different usages of the field in the system. Tends to promote automation Could do something similar with Java Annotations, but this doesn’t tend towards automation, and more towards hard coding
  • I said that we could define each field in only one spot, but even with matrices, there is actually still one spot where you’d have to define the fields again. Anybody see where?
  • One technology for multiple uses, For instance, you start with static fields… (NEXT SLIDE) This leads us into the future of hierarchy
  • *** Between the primitive types and classes, there’s a middle ground that seems to have been missing for years. Javascript found it with JSON, MS found it with LINQ. Hierarchy combines the best of these two into something that is in my opinion has more possibilities than either of these two.
  • This is a simplified version of the website – talk about the website
  • (NEXT SLIDE) What is this type of architecture called?
  • In the past, when we programmed in procedural languages like C and Cobol: Organized by abstraction – elements of your software that were closer to the underlying system lower, top level conceptual elements higher up Now a days, we organize using Object Oriented, general more by behavior Explain how MVC is more by behavioral characteristics. PETER, CREATE HANDOUT OF Procedural, OO and N-Dim version of the architecture Describe benefits of both types of architecture
  • Procedural systems had a tendency to be very well organized in a top-down fashion, making them in certain ways easier to learn and navigate. But tend not to be as well organized with larger systems. Not as natural to group the functions into modules compared to OO.
  • In the past, when we programmed in procedural languages like C and Cobol: Organized by abstraction – elements of your software that were closer to the underlying system lower, top level conceptual elements higher up Now a days, we organize using Object Oriented, general more by behavior Explain how MVC is more by behavioral characteristics. PETER, CREATE HANDOUT OF Procedural, OO and N-Dim version of the architecture Describe benefits of both types of architecture
  • Explain how it works Pros: Visually, it’s easier to understand. Because the different parts of the system are “things,” we can easily see what something is and based on its name, have a good sense of what it does without looking at the code. Objects tend to better define what their responsibilities are then just using methods and modules – so things naturally to group together forming components and subsystems, which means better with larger systems. Because of encapsulation, maintenance is usually easier: easier to find where you need to make changes, and less “ripple-effect” when you do make a change Cons It’s easy to get lost – OO systems can sometimes feel like there’s no overall order for the system. When you follow use case through system, can feel like a lot of bouncing around between objects and components. It’s hard to know what happened before, what happened now, and what’ll happen later Ripple Effect still happens, where you sometimes have to make changes up and down the system to make simple changes.
  • (NEXT SLIDE) What if we had an architecture that combined the benefits of both? Structural - Conceptually well-organized OO – Benefits of real world objects N-Dimensional Architecture does this Uses matrices as its overall control panel into the entire system
  • Actually, one of the original motivations for creating the Hierarchy metacompiler was to be used in N-Dimensional architectures. (NEXT SLIDE) Another technique that’s used in N-Dimensional Architecture is something called, “Universal Data Definition”
  • Actually, one of the original motivations for creating the Hierarchy metacompiler was to be used in N-Dimensional architectures. (NEXT SLIDE) Another technique that’s used in N-Dimensional Architecture is something called, “Universal Data Definition”

Transcript

  • 1. Hierarchy The Next Step in the Java Language Created by
  • 2. Introduction
    • Peter Joh – Head of Development of Hierarchy at our company, Unconventional Thinking
    • 15 years of development experience
    • Several years working on research about Software-Architecture
    • 5 years running Unconventional Thinking
    • 4 years working on Hierarchy
  • 3. Today’s talk
    • Part 1 – Introduce You to Hierarchy
    • Part 2 – Benefits of Using Hierarchy in your Systems
    • Conclusion – The Future of Hierarchy
    • Extra Material – N-Dimensional Architecture - OPTIONAL
    • Discussion – Q & A and Discuss Taking On your Own Software Ideas
  • 4. Part 1 – Introduction to Hierarchy
  • 5. What is Hierarchy?
    • public class MyClass {
    • public void myMethod() {
    • System.out.println(“Some data from a ”+
    • “ matrix: ” + MyMatrix->CONTENT:>SomeData );
    • }
    • }
  • 6. Hierarchy is a Meta-Compiler Pure Java file public class MyClass { public void myMethod() { String myVar = MyMatrix:>SomeData; } } Embedded Java file Hierarchy public class MyClass { public void myMethod() { String myVar = MyMatrix.get_FieldSet() .getField_SomeData(); } }
  • 7. What does Hierarchy Add to Java?
    • Hierarchical Data
    • XML File Type Hierarchy Equivalent
    • .xml -> .matrix
    • .xsd -> .schema
    • .xsl -> .mjava*
    • *.mjava is not quite the same as .xsl
  • 8. Willie’s Petstore
    • news
    • Adopt-a-Pet Day is this Sunday!
    • March 17th
    • Your chance to adopt a lonely doggie is right around the corner.
    • 20% off Fanciful Dog Spread
    • March 12th
    • For one day only, come and pick up your tub of Fanciful Dog Spread!
  • 9. WilliesPetstore.matrix
    • package com.williespetstore;
    • import java.text.DateFormat;
    • MATRIX WilliesPetstore.Content USES (News.Schema) {
    •    NEWS: {"HomePage News Blurbs"} {
    •      NEWS.STORY +`Adopt a Pet`: {     DateFormat.getDateInstance().parse("March 17,2010"),     "Adopt a Pet",     "Your chance to adopt a lonely doggie is right " +     "around the corner."  };
    •     NEWS.STORY +`Fanciful Dog Food`: {     DateFormat.getDateInstance().parse("March 10,2010"),     "20% off Fanciful Dog Spread",     "For one day only, come and pick up your tub of " +     "Fanciful Dog Spread!"     }; }
    • }
    • } AVAILABLE ON HANDOUT
  • 10. WilliesPetstore.matrix
    • package com.williespetstore;
    • import java.text.DateFormat;
    • MATRIX WilliesPetstore.Content USES (News.Schema) {
    •    NEWS: {"HomePage News Blurbs"} {
    •      NEWS.STORY +`Adopt a Pet`: {     DateFormat.getDateInstance().parse("March 17,2010"),     "Adopt a Pet",     "Your chance to adopt a lonely doggie is right " +     "around the corner."  };
    •     NEWS.STORY +`Fanciful Dog Food`: {     DateFormat.getDateInstance().parse("March 10,2010"),     "20% off Fanciful Dog Spread",     "For one day only, come and pick up your tub of " +     "Fanciful Dog Spread!"     }; }
    • }
    • }
    Descriptors Field Sets
  • 11. News_Schema.schema News_Schema.schema package com.williespetstore; SCHEMA News.Schema { DESCRIPTOR +:%NEWS { FIELD.NAMES: { +:%NewsSectionName }; FIELD.TYPES: { :String }; DESCRIPTOR +:%NEWS.STORY { FIELD.NAMES: { +:%StoryDate, +:%Title, +:%StoryContent }; FIELD.DESC: { "The date of the story", "The title of the story", "The content of the story" }; FIELD.TYPES: { +:"java.util.Date", :String, :String }; } } } AVAILABLE ON HANDOUT
  • 12. News_Schema.schema News_Schema.schema package com.williespetstore; SCHEMA News.Schema { DESCRIPTOR +:%NEWS { FIELD.NAMES: { +:%NewsSectionName }; FIELD.TYPES: { :String }; DESCRIPTOR +:%NEWS.STORY { FIELD.NAMES: { +:%StoryDate, +:%Title, +:%StoryContent }; FIELD.DESC: { "The date of the story", "The title of the story", "The content of the story" }; FIELD.TYPES: { +:"java.util.Date", :String, :String }; } } } * Notice Field definitions line up vertically Field Set Definitions Descriptor Definitions
  • 13. How do Schemas Work? AVAILABLE ON HANDOUT
  • 14. WilliesPetStoreConsoleApp.mjava
    • package com.williespetstore;
    • import MATRIX com.williespetstore::WilliesPetstore.Content;
    • public class WilliesPetStoreConsoleApp {
    • public static void main(String[] args) {
    • System.out.println("Willie's Pets and Thingsn");
    • System.out.println("news:");
    • for( DESCRIPTOR<WilliesPetstore.Content->NEWS->NEWS.STORY>
    • newsStoryDesc :
    • WilliesPetstore.Content->NEWS->NEWS.STORY{*}){
    • System.out.println( newsStoryDesc:>Title );
    • System.out.println(( newsStoryDesc:>StoryDate ).toString());
    • System.out.println( newsStoryDesc:>StoryContent + &quot;n&quot;);
    • }
    • ANNOTATIONS {
    • DEFAULT { return null; }
    • }
    • } AVAILABLE ON HANDOUT
    • }
  • 15. Output from Willie’s Petstore Console App
    • Willie's Pets and Things
    • news:
    • Adopt a Pet
    • _________________________________________________________
    • Wed Mar 17 00:00:00 PDT 2010
    • Your chance to adopt a lonely doggie is right around the corner.
    • 20% off Fanciful Dog Spread
    • _________________________________________________________
    • Wed Mar 10 00:00:00 PST 2010
    • For one day only, come and pick up your tub of Fanciful Dog Spread!
  • 16. End of Part 1 – Introduction on How to use Hierarchy
    • For more information, you can download the fairly extensive documentation (and Hierarchy itself) from our website:
      • http://www.unconventionalthinking.net
      • Questions?
  • 17. Part 2 – The Benefits of Using Hierarchy in Your Systems …also, techniques to use hierarchical data effectively in system architectures
  • 18. How is Hierarchy Useful?
    • Think of all the ways we use hierarchical data in our systems:
      • XML config files
      • DB results returned from Hibernate/JPA*
        • (*Not really hierarchical, it’s a map)
      • Spring
      • Web Services
      • JSON Objects in our Javascript
  • 19. Current XML technologies work fine, don’t they?
    • JAXB, JAXP, JDOM
    • Dedicated Hierarchical Data Structure
    • Hierarchical Data as easy to create as a class.
  • 20. Why use Hierarchy?
    • The best of JSON & LINQ
    • Quick look at JSON for Javascript
      • {
      • &quot;firstName&quot;: &quot;John&quot;,
      • &quot;lastName&quot; : &quot;Smith&quot;,
      • &quot;age&quot; : 25,
      • &quot;address&quot; :
      • {
      • &quot;streetAddress&quot;: &quot;21 2nd Street&quot;,
      • &quot;city&quot; : &quot;New York&quot;,
      • &quot;state&quot; : &quot;NY&quot;,
      • &quot;postalCode&quot; : &quot;10021&quot;
      • }
      • }
  • 21. Why use Hierarchy? (cont)
    • Quick look at LINQ for C#.Net
      • int someValue = 5;
      • var results = from c in SomeCollection
      • where c.SomeProp < someValue * 2
      • select new {c.SomeProp, c.OtherProp};
      • foreach (var result in results)
      • Console.WriteLine(result);
  • 22. Hierarchy combines the best of both these technologies
    • Adds powerful but simple hierarchical data-structure to Java
    • Technology with lots of potential
  • 23. Next usage of Hierarchical Data: Universal Data Definition Questions?
  • 24. Problems with defining fields
    • Ex: Creating an online registration form:
    • Enter Your Info:
    . . . Address Last name First name
  • 25. Fields defined in multiple places DB hibernate.cfg.xml public class MyClass { String firstName; String lastName; } JSF or JSP or HTML page Javascript JSON object
  • 26. Universal Data Definition
    • Define all the usages of a field in 1 spot:
    • MATRIX MyWebApp.Matrix USES (WebForm, Database, JSON) {
    • `First Name` {
    • FORM.REQUIRED: { +:IsRequired };
    • FORM.CONTROL: { :TextBox, 30 };
    • HELP.TEXT: { “Please enter in your first name” };
    • DB.COLUMN: { +:Customer, +:First_Name, :”VAR_CHAR” };
    • JSON.FIELD: { “myJsonObj”, “firstName”};
    • }
    • `Last Name` {
    • FORM.REQUIRED: { +:IsRequired };
    • FORM.INPUT: { :TextBox, 30 };
    • HELP.TEXT: { “Please enter in your last name” };
    • DB.COLUMN: { +:Customer, +:Last_Name, :String };
    • JSON.FIELD: { “myJsonObj”, “LastName”};
    • }
    • }
  • 27. Another look at previous slide… DB hibernate.cfg.xml public class MyClass { String firstName; String last Name } JSF or JSP or HTML page Javascript JSON object
  • 28. Persistence for Hierarchy
    • Not object-relational mapping like Hibernate / JPA. It’s a full persistence server
    • Extremely easy to use
    • Working alpha
  • 29. One Technology for multiple uses
    • XML Config files
    • Spring
    • Object-Relational Mapping (Hibernate)
    • True Persistence
  • 30. Future of Hierarchy
    • Finish Beta 2 fixes
    • Finish Persistence
    • IDE Integration (Eclipse, Netbeans)
    • View Language (Already designed)
    • LINQ or Hibernate like functionality
    • Also, remember, Matrices are not static xml. They are a new data structure in Java! More possibilities for new uses
  • 31. Future of Hierarchy (cont)
    • Issues to AVOID with User Adoption
      • Poorly implementation & buggy
      • Tough to work with
      • Not enough supporting tools
      • Nobody knows about the Hierarchy!
    • Released open source in the near future
    • Only ~30% of what we had planned
      • Excel-like tool for CMS
      • New architectural language elements w/ IDE tools
      • New tools for creating meta-code (like JSP’s)
    • Contribute your time & Looking for business to partner with!
  • 32. Please Contribute your Time! change Java
  • 33. Thank you! Optional Extra Material: N-Dimensional Architecture Before Proceeding, Any Questions?
  • 34. New architectures with Hierarchical Data
    • Collect all the settings and content together in matrices
      • Similar to what we did in the running example
    • Put things that change the most together
    • Very similar to what happens in Spring
    • Unconventional Thinking website was done using this technique ( Handout )
  • 35. Real World Results of Collecting Settings into Matrices
    • Easier to maintain – one spot for all changes
    • System Design tends towards automation
    • Simpler architecture, Less code
  • 36. Past & Current Architectures
    • Architectures for Structural Programming
    • Architectures for Object-Oriented Programming
  • 37. Structural-Programming Sample Architecture main() main() { initialize(); run(); cleanup(); } initialize() run() cleanup() getConn() gatherNews() formatNews() News App
  • 38. Pros & Cons of Structural Programming
    • Pros:
      • Conceptually well organized
      • Easy to Navigate
    • Cons:
      • Tend not to be as well organized with larger systems. Not as natural to group the functions into modules compared to OO
      • Harder to visualize, so harder to learn
  • 39. Object-Oriented Sample Architecture NewsGatherer initialize(); gatherNews(); NewsCollection initialize(); getData(); NewsFormatter cleanData(); formatData(); NewsDisplay displayNewsData(); NewsFormatter cleanData(); formatData(); Model Objects View Objects
  • 40. Pros & Cons of Object-Oriented
    • Pros:
      • Visually, it’s easier to understand. Because the different parts of the system are “things.”
      • Objects better define the different responsibilities of system.
    • Cons:
      • It’s easy to get lost – OO systems can feel like there’s no overall organization of the system.
      • Ripple Effect still happens, where you sometimes have to make changes up and down the system.
  • 41. N-Dimensional Architecture Sample Control Layer Execution Layer Services Layer News Settings – contains settings across entire app Presentation Cross-Section Business Logic Cross-Section NewsGatherer Service Gathers news from collections HTML Table Renderer Displays news in tables View-Related Services Data-Related Services NewsView Worker Displays news as HTML News Scheduler Schedules news gathering News – wrapper for entire news service
  • 42. N-Dimensional Architecture Summary
    • A new architecture based on our research.
    • Organize you system in multiple ways at the same time.
    • The technique we spoke about, “Collecting all settings and content together” is a using this architecture.
  • 43. N-Dimensional Architecture Pros & Cons
    • Pros
      • Easy of navigability and better sense of natural layers of system
      • While retaining feel of real world components
      • Tend to be Automated
      • Tend to be Developer-Oriented
    • Cons
      • Not as useful for libraries and services
  • 44. Thank You Q & A and Discussion About Taking on your Own Software Ideas Peter Joh [email_address] www.unconventionalthinking.net