July 19, 2008

RADE Milestone – Object Relational Mapping with NHibernate

Filed under: RADE — Tags: , — Darrin Maidlow @ 3:37 am

It’s 1:30AM, I guess it’s Saturday now. =)  I’ve been furiously pounding away for the past two weeks building a new for RADE 4.0.  Gotta love 12 – 18 hour days for two weeks (Good thing I love software development).  My wife is away for the week, so I can continue working these stupid hours for another week.  Anyhow I’ve chosen to proceed with for the time being.  with the looks really cool and I’ve used it for some small research/test projects recently, but with the lack of support for database other than SQL server – it’s not an option at this time.

NHibernate was a tough curve for me.  Initially, I started testing code generators.  After spending a significant amount of time reading, testing, and pulling out hair I came to the conclusion that .  From my experiences is probably the best code generator out there right now – but its still lacking in some areas.  More importantly however, I learned that code generation is not a good place to start when implementing NHibernate for the first time.  There is so much going on under the hood – in my opinion you need to start off doing a reasonable size project by hand.  Code generation has significant benefits, because the generated code is so similar with simple replacements it just makes a lot of sense once you wrap your head around what’s going on with NHibernate.

As per my when implementing nHibernate by hand, .  Just the other day I found a *great* ReSharper .  When editing NHibernate HBM XML files, it does a bunch of validation right in the editor.  Saves you a lot of time finding problems without having to actually run a unit test and debug sometimes cryptic error messages.

I bought a copy of NHibernate In Action.  I would recommend this book to you only if you have no experience, or understanding of Object Relational Mappers.  As the book stands right now, it’s not really a good developer reference and only covers really basic examples.  The documents that helped me the most to get everything up and running was .  The NHibernate documentation is pretty cryptic.  Don’t read this stuff 12 hours into your day.  No amount of RedBull will give you the focus needed to make sense of it.  In the first 8 hours of the day, its quite helpful.

I primarily work in VB.NET.  For this project however, I switched to C#.  Maybe now, the my colleagues at will stop giving me a hard time =).  Seriously though.  Examples are a LOT easier to come by in C#, probably 10:1.

Finally, get NUnit running.  I had a lot of problems using the built in Microsoft Test projects with NHibernate – so I’ll be sticking with NUnit. If you’ve never done unit testing (you know who you are) do it.  Particularly in this case – its crucial.  You (Again you know who you are =]) used to write simple winform apps, and put a bunch of buttons on them.  Don’t do that. 

So, if you are one of the RADE non-developer users and you read on this far.  Congrats.  This milestone will not directly help you with your use of RADE.  However, it’s a large step forward for the underlying architecture – and you will benefit from that. 

Well back to Visual Studio I go..

Technorati Tags: ,,,

2 Comments »

  1. I know the feeling; my problem is that VB.NET is my strength and C# is not. So if I work in VB I spend a ton of time looking for examples and if I work in C# I spent time as well, just figuring out syntax and such. It’s like being between a rock and a hard place. I have considered making the jump but VB is sooo comfortable right now :) Aside from programming preferences and availability of samples would you suggest other compelling reasons for switching from C# to VB?

    Comment by Sierk — November 12, 2010 @ 1:45 pm

  2. Well its been a couple of years since I wrote this – and I’m totally happy with my choice to switch to C#. All new code is done in C#, but I still have a ton of code in VB. Each time I need to work on a chunk of VB code, I decide whether to patch the VB or invest the time to re-write it in C#. I can’t explain it – but working in VB actually makes me a little sad now. Maybe its just nice to change things once and a while?

    I’m completely in love with ReSharper – which had/has more complete support for C# (though I believe they’re adding VB support more and more). Finally, It seems to be easier to find new team members because the C syntax is so prevalent.

    Rather than jumping ship completely – try using C# on a new library or small project. I used to use the online VB.NET to C# conversion tool a LOT – even now I’ll take an entire class of VB and convert it to C# and see how much good code I can pull out of the VB – at the very least you can get your event handlers and stuff moved over pretty quickly. (ReSharper really comes in handy refactoring this converted code)

    hope that helps =)

    Comment by Darrin Maidlow — November 12, 2010 @ 3:42 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

Switch to our mobile site