|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Aim of the articleRecently, I evaluated some of the open source code generators and ORM Frameworks in .NET. To my surprise, there were quite a few of them in various stages of development. This article tries to provide an overview and links to the resources that I found useful during this evaluation process. IntroductionThough we probably don’t realize, we have been using code generation since the day we compiled our first C (or assembly program!) program. The C compiler converted our C program into code that was understood by the machine. Code generation can be defined as:
The main purpose here is to eliminate writing repetitive and static code that can be auto generated. With every new release of Microsoft's developer tools, some parts of mundane coding tasks are automated. The days when I used to type in 100 lines of code to create a simple "Hello World" Windows application, now seems so naive. With the need for writing code to generate UI screens almost eliminated (thanks to Visual Studio and other such IDEs), and programming becoming more abstract, the next target is automating application development for enterprise applications. Model Driven Architecture (MDA) is a step towards this direction that focuses on domain and process models as a means of application generation. There are quite a few tools (mostly commercial) available, claiming to help you realize application generation. But due to the prohibitive cost, proprietary architecture, and complexity, their acceptability and proliferation is still low. Most of the current tools claiming to be MDA tools are advanced CASE tools, or code generation tools, but we are surely getting there. For more details please check the following links:
Check out some interesting products from IRISE and also Softrock systems that support application simulation using UI models. Till these tools get cheaper and are easily available (so that I can get a copy and evaluate them in my spare time), let’s focus our attention on ORM and code generators which can automate the creation of data access layer and web pages at least for CRUD operations on database tables. Why automate code generation for CRUD?
DALs/ORMIn a database application, the Data Access Layer acts as a bridge between the data tables (Relational Universe) and business objects (Business Domains); and in the .NET world, more often than not, these are built as extensions to the ADO/.NET Object Relational Mapper, as the name suggests, provides framework which maps relational data to objects (Business Objects). If you are interested in more detailed explanation on the theory behind ORM, please check the following links: Many of the OR Frameworks generate (or require you to create manually) classes (objects) based on domain models, while their framework classes take care of mapping and formatting of data, so that it persists safely and accurately. There is considerable amount of interest in the developer community with regards to ORM, and many perceive it as the next big thing in software industry. So, when there is so much going around, can Microsoft be far away? Absolutely not; they are working on something similar. Long back, they had announced they will have some thing on ORM, which was then termed as Object Spaces. It was supposed to be released with .NET Framework 2.0, but it was conspicuous by its absence in the beta release. Here is the link to MSDN which currently doesn’t give much information. But there are a few links that provide you some insight into Object Spaces.
What are the ORM tools available for .NET in the market currently?There are lots of ORM solutions available for Java (guys, it's just because it has been there for few years from now :) ); but surprisingly there are quite a few solutions available for Microsoft .NET. Here is a small list (thanks to Yves Reynhout and Sharp Tool Box):
Some other interesting frameworks:
To see the updated list, please visit Sharp Tool Box's List of OR Mappers (Sharp tool box website contains a wealth of information about various tools available for .NET, make sure to visit them frequently at SharpToolbox). Also, Microsoft is working on data mapping application block that will (was supposed to) be shipped as a part of Enterprise application block (any connection with ObjectSpaces :-?). For more details please visit: Data Mapping Application Block Work Space. Criteria for evaluating ORM toolsWith so many of these tools/framework available, which one to choose? Well! If the answer was simple enough, we probably would not have so many products in the market. The best advice probably will be to evaluate products against the requirements you have. Some of the common criteria that you can use:
Fabrice Marguerie has provided a detailed list of criteria that you can use to evaluate an ORM tool: Evaluation Criteria for ORM. If you want to read some interesting debates about which ORM is the best, please check out the following discussion (have a cup of coffee ready it’s a long night!) I will try to give you an overview of a few of these technologies in another article. I plan to start with Nhibernate. Nhibernate is very flexible and is a part of a highly popular and established Hibernate Framework for Java. It provides you with a framework for eliminating/reducing (I prefer simplifying) the amount of code that needs to be written for DAL. Code generationWouldn’t it be nice, if there were tools that (given a database and a table in that database) did the whole bit of magic and generated a C# solution, which will have a GUI for all the basic CRUD operations along with the DAL? I bet that would be nice!! Well, we are not alone; there are so many people who have thought of this before us. To get the list of these tools you just have to click the link! C# Code Generators. I have used IronSpeed (it is much more than a code generator), and is good at what it does. It also makes, creating "Professional looking" database application very simple. But it’s not free and also does a lot of things "magically", without allowing me to control them (newer version allows more control though)! Some of the free source code generators are: MyGeneration: A highly recommended template based code generation engine, written by Mike Griffin and Justin Greenwood of MyGeneration Software. They have also committed to keep version 2.0, which is planned for release by the end of 2005 as a free product. With ASP-like syntax, flexible UI, and good community and developer support it's a product that's ready for prime time. CodUS: Codus is a comprehensive code generation tool for object-relational mapping. It takes an existing database and automatically generates all the code for updating, deleting, inserting and selecting records. In addition, it creates web services for distributed programming, strongly-typed collections, and a full set of unit tests. I haven’t got an opportunity to test this product, but it looks very promising (hopefully I shall get an opportunity to experiment with it soon). Olymars: SQL Server Centric .NET Code Generator (code named OlyMars) is both a flexible and powerful code generator based on database modeling. This is a free and unsupported product from Microsoft. I was not updated for quite some time, hence found it a little difficult to understand and use. Nvelocity: based on velocity, a highly popular template engine for JAVA. This project has been abandoned for lack of community support. (Come on .NET dudes wake up let’s start building strong open source community, aren’t we fed up of taunts from these JAVA guys.) M3rlin: is a template code generator that uses ASP.NET style syntax. It hosts the ASP.NET runtime to perform code generation. It uses XML as it is the source of meta-data. MyGeneration so far as I have understood stands above the rest, with its flexible template based approach (in four different languages- JScript, VBScript, C#, and VB.NET), long term commitment from the developers, and an active community support. For details please visit:
I hope you find this article interesting and useful. Till next time, Keep learning!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||