Karl Why Did You Write XAML Power Toys and What is Ocean?

In the last few days I’ve been getting questions about XAML Power Toys like; why did I write it; what was the motivation behind the work, etc?

I was actually beginning the UI development in my soon to be released Ocean Platform (details below) and found myself looking at creating 8 forms for Ocean’s metadata maintenance and code generation.

I was thinking, if I lay Ocean down for a week or two, I can write a tool that will allow me to author Ocean’s UI in no time at all.  Ocean has it’s own built-in advanced UI generation but Ocean is designed to consume metadata.  Since I didn’t have metadata yet, I needed to tool to help me author the UI forms. 

You see, I really didn’t want to hand type 8 more forms if I could get the computer to do it for me.  So because I’m lazy, XAML Power Toys was born.

Time

Time is one resource that can not be replaced.  It goes by so fast and seems to slip between our fingers very easily.  It’s vulnerable and somehow “things” inject themselves into our time.

As developers, we can (should) take steps to maximize our time.  We can maximize our time by having the correct tools, proven workflow and an understanding how to use these. 

We developers need to manufacture time by accomplishing tasks faster and with laser surgery accuracy.  In our world the goal is to deliver defect free, maintainable, standards based code.

The best way I know to meet this goal and to manufacture time is to generate as much production code as possible. 

This gives the developer more time to allocate to a better application design, to learn new patterns and to keep up with the flow of new technologies that can only be compared to the water flowing at Niagara Fall’s.  I wrote Ocean to give me time back.

Ocean

Back in May of 2008 I wrote this blog post:  Metadata – a Voice Crying in the Wilderness, Hey! I’m Over Here.  This was a call to architects to consume the warehouses of metadata that most projects have but do not ever get into the hands of the developers.  You say that’s not entirely true.  OK, then why do developers type ToolTip text into their forms?  Why is a developer typing XML comments on business objects? 

These are two over simplified examples of metadata that is located in a design document somewhere, but is not in a format or physical location that makes it easily consumable by the developer or a code generation product.  The term disparate data storage comes to mind.

I strongly agree with one of my mentors, Bill Jones that developers should own their code generation system.  We live in a very fast and volatile world.  Things simply change a lot.  Today’s architects and developers need full access to the code generation system’s data model, templates, template engine and generation code.  Yes, I know this will raise a few eyebrows, especially if your company provides Code Generation software.  But I wrote Ocean because I couldn’t find an off the shelf Code Generation product that did what I needed, was easy to understand, manage and had examples for VB.NET developers.

Right behind code generation an application of any size requires a set of libraries that sit on top of .NET that provide the services a Line of Business (LOB) application requires.

Ocean provides a light weight, comprehensive framework that works in WPF and Silverlight.  This was one of the requirements of Ocean, that it support Silverlight. 

Ocean is divided into five assemblies and I’ll be adding one more that is specific to Silverlight.  Below are some of the highlights of each assembly.

OceanFramework

  • Ocean is the UI for maintaining the metadata the Ocean Code Generator consumes.  It also makes calls to the OceanCodeGenerator to generate an object like a stored procedure, trigger, DAL, BLL, entity object or UI object.  I’m going to also add support to generate MVVM ViewModels.
  • OceanCodeGenerator is an ASP.NET web that runs in a secondary AppDomain under Ocean’s control.  This assembly takes a request from Ocean and generates an object.
  • OceanFramework is the code that runs in WPF and Silverlight.  It requires no code changes between the two platforms.  This assembly provides declarative validation on business entity objects, UI case correction and business entity base classes.  The validation is attribute based, but can also be declared in code.  Compiled, this library weights in at only 62KB.  For Silverlight, that is a real winner.
  • OceanFrameworkSQL is a light weight and super fast replacement for the DAAB I loved in .NET 1.1.  This library weights in at 29KB.  In addition to enabling single line of code database calls from your DAL, this library also has built in concurrency checking and object building from a DataReader or DataRow.  I’ve run tests and was able to build 19,000 unique objects per second using this library.  This is on par with LINQ To SQL and other object loading techniques.  Check out my three blog posts on Performance to review the test data.
  • OceanFrameworkWPF provides WPF specific code, commands, converters, UserControls and Custom Controls.  Most of this code is already on my blog.
  • OceanFrameworkSilverlight to be written soon.  Will provide Silverlight specific code and controls.

Ocean’s Workflow

Ocean does not claim or attempt to be all things to all developers.  It is not a silver bullet.  It’s a metadata driven LOB application development and maintenance tool.

Note that the Ocean libraries can be used without the code generation pieces.  You have probably noticed the XAML Power Toys uses the OceanFramework library.

My current workflow is:

  • Design the data model using SQL Server Tools
  • Sync Ocean with that database
  • Enter in all metadata for the application
  • Press a button and all the stored procedures, DAL, BLL and Entity objects are immediately generated
  • Easily generate additional required stored procedures, DAL, BLL and Entity objects for subsets of a class.  For example, the customer class has 25 properties.  The customer search results only has 5 properties.  Ocean allows you to create everything for this search results class in a split second and assists you with creating the DataTemplate for the UI.
  • Use Ocean to generate each UI object as the developer requires
  • Ocean handles changes to the data model and application requirements with ease by allowing some or all objects to be recreated on demand.

Closing

So on nights and weekends, I’m back to working on Ocean and hope to ship, including detailed documentation by the end of October or early November.  When released, Ocean will appear on Code Project and my blog. 

I’ll be presenting Ocean and doing walk through’s in the open spaces at the Fall Raleigh North Carolina Code Camp on 15 November.  Register if you’re in the area or can make the trip.

Have a great day.

Just a grain of sand on the worlds beaches.

14 Responses to “Karl Why Did You Write XAML Power Toys and What is Ocean?”

  1. peteohanlon Says:

    Karl – it’s interesting that you are doing this. My background (years ago), involved writing a model based system generator for creating applications from database held meta models. This system used an early workflow engine, business rules engine and forms generator to crank out insurance applications in Informix, and then Oracle.

    Since then, I’ve seen many application generators, but very few that actually work from the model. They tend to assume that you generate a class per table, and completely miss the point about the differences between normalized databases and OO concepts. Some efforts, such as NHibernate and Entity Framework go someway towards addressing the differences, but they still have deficiencies because they assume that you want to code from the database point of view rather than the model point of view. Once you have the metamodel defined, then the database code should be trivial and unimportant in terms of the application. Also, the database should be generated from the metamodel.

    I started writing my own framework for this a while back, but couldn’t devote the time to it that I wanted to because of other commitments. Here are some of the features that it was moving towards (maybe Ocean will be the push for me to get back to it):

    1. An attribute, in the meta model, should be defined only once. It can be used in many places, but the definition exists only once.
    2. Attributes can be grouped – so, suppose you had an attribute called Date and another attribute called By, this could become part of a new attribute group called Modification, which would give you the ability to add attributes called Changed and Created. These would give you ChangedBy, ChangedDate, CreatedBy and CreatedDate fields.
    3. Change to the meta model should be impact assessed. The fact that you are generating your model from the metamodel means that you can assess exactly what code and database elements will be impacted by changes.
    4. Layers should be generated from the meta model. This one’s self explanatory.
    5. Validation should be defined on the meta model. Again, self explanatory – define the validation on the model, and the code will be created automatically.

  2. Karl Shifflett Says:

    Pete,

    Thank you very much for your feedback. I’ll contact you offline in a week or so.

    Cheers,

    Karl

  3. peteohanlon Says:

    Karl – I just reread my comment, and realised that it’s come out sounding a bit harsh and critical – it isn’t meant to be. I’m looking forward to seeing Ocean, and am sure that you’ve considered a lot of the deficiencies that I talked about. Hey, I’ve seen your code – so I know I can trust you.

    More importantly, you’re talking about Ocean coming from the right side – the meta model. This is where most ORMs go wrong.

    Pete

  4. Karl Shifflett Says:

    Pete,

    Not at all. I’ve had to make hard choices to be sure. Just like the rest of the world. I’m looking for Ocean to be simple to setup, use and maintain code.

    I’ll hook up offline in a week or so. Looking forward to getting your input.

    Cheers Mate,

    Karl

  5. peteohanlon Says:

    Cool. Looking forward to it. It’s always good to see what others come up with.

    All the best mate.

    Pete

  6. tkd99 Says:

    Hi Karl

    This looks really interesting. Couple of issues I am struggling with that you migth like to consider in your examples. I’m not sure whetehr the scope of what you were doing will cover these.

    1. You are basically talking about one-way code-generation from the model? If my model changes will I need to manually add the changes? If I regenertae the changes then do I lose my business rules and stuff?

    2. Master detail type objects. Most of the examples I have seen are simple single entities. But how would you handle somethign like an Order with OrderDetails. Would eachOrderDetail be its own object that woudl require its own loading and saving? Would there be a means of consolidating this to improve performance?

    3. Distributed systems. I would think that silverligth would have to fall into this type of area. But even in a WPF I want a distributed system where I can creat by entities at one end, stream them down to the client, work on them and then stream them back. Again for single entities reasonably straight forward. But when you start getting back into master detail examples, you have to be able to accruately track the changes to OrderDetails (including deletes) and stream this back to the server.

    Cheers

    Jeff

  7. Karl Shifflett Says:

    Jeff,

    Thanks for your feedback.

    1. No nothing is lost.
    2. This is a VERY long discussion that I may write about. I’ve heard many talk about client side caching is better performance, but I’m in the other camp, BIG TIME; coming from a DBA’s point of view and a simpler development model. It comes down to what metrics you use to measure perfomance. # of hits on the database, # of bits flowing, size of the database, remote verses local clients, how volitle is the data, time lost to concurrency resolution due to stale data in a clients cache, through put, transactions per second, etc… … …

    The solution that I use, covers all of these scenarios very well and scales.

    Ocean does not pin you to doing things my way, not at all. You can do anything you want.

    3. This is very easy in Ocean, trust me. In fact, in my examples, I only send back dirty OrderDetail rows from Silverlight.

    Closing: I’ve developed this entire platform on my own, using my coding style and things I’ve learned over the last 20 years in IT.

    I’m sure that some will love it, other will like it, others will take a pass. This is as it should be. Otherwise we would only need one flavor of icecream at the market. This is why we have the CSLA, Enterprise Application Blocks, other freameworks, commerical products and soon Ocean.

    Oh, Ocean is free and you are free to change any template or anything about it.

    Cheers,

    Karl

  8. tkd99 Says:

    2. Not sure that answered my question but certainly very interesting. I was talking moreabout how intelligent the object creation was for master/detail type objects.

    3. And it handles deleted order details as well? So the details are deleted from the collection so you don’t see them in the grid, but they are streamed back ok? This is the one that makes collection handling difficult. You usually either need to have a specialised collection container that can track the deletes or you use something like a unitofwork container.

    CSLA is one of the frameworks that has my interest. I prefer the idea of having the object streamed to the client and the rules handled at the client end, because it results in a more responsive and useful user experience IMHO. But then I was reading your blog and thought that sounded cool. So now you just need to hurry and finish it or at least start releasing some further blogs about how this is going to work. :-)

    Thanks

  9. Ocean’s Birthplace « Karl On WPF - .Net Says:

    [...] I’ve been blogging and speaking about Ocean and wanted to share the birthplace of Ocean with you.  Ocean was born [...]

  10. bibjp Says:

    Hi Karl,

    I’m very interested in Ocean Framework to develop a personal application with many database tables…
    I see a capture shwoing a project named “OceanCodeGenerator” but i didn’t find any place to download it (neither in CodeProject).

    Could you tell me if this project can be downloaded or not ?

    Thanks in advance.

    JP

  11. Karl Shifflett Says:

    JP,

    I had to hold off delivering the Code Generation code. The blocking issue for delivering this code has been removed. I’m back to working on it and the documentation. I will be posting it as soon as the documentation is completed.

    Cheers,

    Karl

    • daveker Says:

      Hello Karl
      I caught your presentation in NYC and you were great. I’m now hooked on this blog. Your articles are very informative, easy to read and thank God in VB. You have helped me a great deal and I appreciate it. I am anxiously awaiting seeing the code generation code for Ocean. Is there any projected date for its release?

      Thanks again
      Dave

  12. daveker Says:

    Thanks Karl

Leave a Reply

You must be logged in to post a comment.