Evaluation of Code Generator

CodeSmith 4.1
Pros:
– UI very good.
NTiers template looks pretty cool, using Enterprise library and Entity Provider pattern. But this is too complex for me. I still prefer MVP + NHibernate.

Cons:
– NHibernate template doesn’t support View. When using table I got a error said can not find primary key in our database enviorment.

SmartCode 2.0
Pros:
– Opensource.
– Output can include DaoFactory, DomainObject (ancestor), Interface of DomainObject, almost every thing in DAL. I think Billy McCafferty is using this tool.

Cons:
– Datasource configuer window is not very user friendly.
– Couldn’t regconise our no-primary key table.
– View list is not sorted. Very difficult to use.
– Changing template has to go through rebuild the project provided as source code. No wonder it’s open source. This work is annoying.

MyGeneration 1.2.07
Pros:
NHibernate template can support view, including no-primary key view.

Cons:
– UI too simple.
Not opensource. OpenSource started from June 2007.

Most of our tables don’t have primary key instead we are using identity column. (Our DBA just like this way, I don’t know why.) Because SmartCode is the only one has source code, so I can modify it to make it meet my requirements.

I followed the templates of MyGeneration, then I realized that even MyGeneration failed to get my identity column. But the thing is MyGeneration didn’t quit, instead it printed out a line:

<!– could not find a primary key for this table/view. NHibernate requires an ‘id’ element, so you’ll have to define one manually. –>

It’s not hard to change SmartCode to follow the same routine. Only minutes of work. Theoretically, I could make the same change to CodeSmith Template, nut when I tried to change TableSchema to ViewSchema to enable ViewPicker instead of TablePicker in CodeSmith’s NHibernate Template, it turns out CodeSmith cannot change type ‘SchemaExplorer.ViewSchema’ to ‘SchemaExplorer.TableSchema’!

None of those tools can generate many-to-one relationship in class or hbm files based on our view-only database, which makes sense to me, our table/view don’t have foreign key or reference.

Obviously, NHibernate hates DBA , and vice versa.

After closely looking into the generated templates, I start to admire MyGeneration. Their class file looks more professional, with region tag and two flags: isDeleted and isChanged (don’t know how to use yet. But isn’t that thoughtful?)

Yes, I can change the templates in smartcode to get the exactly same result, just need some rearrangement work. But I don’t want spent more time in it. Tools are good, but don’t addict into too much.

Advertisements

9 thoughts on “Evaluation of Code Generator

  1. There are a mistake in your artice….Smart Code allows to generate many-to-one relationship for NHibernate templates, inclusive create the relationship in the Smart Code Studio, look for LOV concepts.

    Danilo

  2. To Danilo,
    Thanks for pointing out that. Yes, Smart Code can do that, same as others. But what I tried to say is, our complex database system only expose views to developers, so there is no foreign keys available when using those tools. It’s our database security problem, not Smart Code’s fault.

  3. Hi Frank, NConstruct Professional is a commercial product and you can get it here: http://www.nconstruct.com/App/Purchase.aspx?PageId=5. It doesn’t create only NHibernate mapping files and C# classes, but also the whole working application (applicaton server + Windows client and/or Web ASP.NET application) with security & user management, offline concurrency, app/user settings module etc.

    It depends what you need – if you need only mapping code generation, free NConstruct Lite will do the job as well as NConstruct Professional.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s