As a token of appreciation to the Dream in Code community, we propose a free CodeFluent Entities Professional subscription-based license valid until December 31st 2013. This is a one-shot operation as part of the partnership between SoftFluent and Dream in Code. This offer ends March 31st, 2013!http://www.softfluen...e-special-offer

I recently had a chance to review Softfluent's "Codefluent Entities" (CFE) add-on for Visual Studios. Codefluent Entities is a code generator that really helps channel, and push, the upfront modeling and architecture we all do (or should be doing) when we dive into a project.

Over the years I have looked into multiple avenues for marrying my diagrams and planning with the ability to generate usable code from that process. Mostly to save time, but also to have a solid visual overview when I go back and track why one entity (or object) butts up to another and their relationship. Of the processes and routes I have looked at, Codefluent Entities has come the closest to having all the elements I tend to need *AND* is a stable product that integrates wonderfully with Visual Studios (and doesn't crash it). That isn't to say I don't have some niggling issues, but the overall product definitely outweighs them.

Who is it for
First and foremost (before I dive into the workings of CFE) this is a Visual Studios add-on; specifically Visual Studio 2008, 2010, and 2012. Second it looks to be a primarily a 4.0 framework. Third this really hits hard on the object orientated programming. IF you are not too keen on the whole 'OOP' train then the usefulness of this substantially declines. Still with me? Awesome - let continue down the tracks.

Why use it
Codefluent Entities is what they call a 'model first' approach to writing a program. Specifically this is a 'single pragmatic model' setup; not ORM and not UML. When you have your idea for an application (or after you have your first meeting to get the specs from the customer) what is the first thing you do? You start scribbling out the architecture that will be the basis for the entire app. This may be on a white board, a in a notebook, or on the back of a napkin. Boxes for different classes needed, propertie and methods required, and how those objects relate to each other. This has the added benefit of knowing what work needs to go into the application, fleshes out your system requirements specification, and identifies problem areas. All the great and wonderful planning that goes in before you get your hands dirty with coding up the application.

Primarily CFE provides a way to take that abstract model and put it to tremendous use - by generating all the code and relationships for you! It takes the model off the whiteboard and puts it to work. This is a tremendous boon on time, minimizing errors and mistakes, and also allows you to take that model and generate code in different languages and for different platforms. All... in.. one.. tool! Sure this may not be the best route for small one off apps, but for larger complex systems spread out on different platforms it is hard to beat the time saving of taking a tried and tested model from one system and not having to recode it for three others.

How it works
The way this works is you design your model in the CFE project template. Create classes and objects, fill in what you need for properties and methods, and start linking relationships. It is all there, visually, on one screen. Once you created your model CFE turns around and feeds this model to 'producers'. This is where you can tell CFE what language you want this to be compiled in, create database scripts based off your models, and updates program wide changes with a click of a button. The output from the producers is then referenced in your application and you interact with it as if it was a class you coded up.

A screenshot of the producers available.

When I first approached CFE I took a more bullish course. I installed the free personal download, watched their webinar videos, and took off head first into creating objects. Now I could have saved a bit of headache by reading through their documentation, but I am honestly surprised how far I got with just a mad dash approach.

Let's take a look at some screen shots and see what you will be getting into. With the free personal license you get a bevy of project template examples to poke through and a blank template for when you are ready to start.

Here I have a simple 'Item' class I was planning on using later for a inventory and shopping list application. Here you can see clearly marked properties, a method to return a string of said properties, and even an enumeration (with a visual line linking the enumeration to the property). Oh, did I mention you can write the code in a little popup window and have it generate with the model? Yes a nifty feature that lacks moderate syntax checking, but it really helps flesh out those entities.

When I click on the ID property here are the properties for it. A whole mess of scenarios and usage already baked in and ready to use!

The 'business object' producer is a pretty simple form where you specify who gets the compiled model, and in what language.

Here's a view of a simple project setup I rigged up. The top is the CFE solution.. the BOM producer shoots the code over to the class library project (middle), and finally my console application is shown utilizing the object created from the model. As an added bonus CFE has three great events wired in: PropertyChanged, EntityAction, and KeyChanged. Pretty basic, but required, events I would use. while I am thinking of other thoughtful addons - each object also has a working collections object created if you need it. No more using generics!

See - an overall well worked out process. Now that was a basic one object setup, but here is something a bit more complex. With this I have a similar item object but it is connected (a many to one relationship with a list object.

The key factor is here I have a 'producer' that is generating all my stored procedure needs for this app. I am talking tables, relationships, load stored procedures, save, delete, views, and so on. No need for tedious work (oh and the items have built in methods that hook up to the DB procedures already!).

SQL Producer:

Procedures created:

Tables created:

For fun - here's a screen shot of the pre-existing template Codefluent Entities gives you as a 'bug tracker'. Substantially more complex than my last example, but certainly you can grasp what is happening with just a glance!

At the end of the day can you get by without Codefluent Entities? Certainly. You can continue maintaining documentation and relationships on a whiteboard, model architecture by hand, and making sure an update to an object is correct over all your platforms and references... or you can use one tool to create your model and with a few clicks update all your environments and generate *USABLE* code for workspace. This tool may not be best for all projects you encounter, but for those particularly large scale, and pervasive, app Codefluent Entities certainly can be a driving force to get the work done correctly the first time, react to changes later down the road, and possibly speed up your development cycle. Personally I will continue playing with the tool and shoring up my architecture first modeling processes!

At the time of writing this the 'personal edition' is free to download and install. I would encourage you to check out. Watch their webinars, and peruse the documentation. At worst you gain a bit of insight modeling your objects, and best maybe you find a great tool for that toolbox!

As a token of appreciation to the Dream in Code community, we propose a free CodeFluent Entities Professional subscription-based license valid until December 31st 2013. This is a one-shot operation as part of the partnership between SoftFluent and Dream in Code. This offer ends March 31st, 2013!http://www.softfluen...e-special-offer