So rather than list my grievances with NHibernate, and the reasons behind my decision to move on, I just want to drop a quick sketch on how I’ll probably be designing systems in the future. I’m really excited about this. Here are the layers involved.
- Phsical Database. SQL Server. No surprises here.
- Data Access Layer — EFv4. Not using POCOs, but not lazy loading either. Lazy loading has been giving me headaches with serialization and AutoMapper. Plus it’s…lazy. You should know what you want, and eagerly fetch it.
- DTOs (Data Transfer Objects). I’ve written some T4 templates based on the EF POCO templates to auto generate these classes from the edmx file. If you update your model, these are automatically updated too. Also (again with T4 templates), I’ve created AutoMapper configs to convert both ways (EF entity => DTO, DTO => EF entity).
- Service Layer — WCF REST, with as little config as possible. This is based on the downloadable WCF REST templates in VS2010. Also, I’m using Json.NET to serialize/deserialize all of my DTO types, simply because it can handle cycles, and I like control over how dates are serialized.
- Web UI. Still some decisions to be made here. I haven’t dived into MVC yet, but I’m not really using Web Forms either. Right now in my example solution, there’s nothing in the code behind files, I have no post backs, no server controls, and no viewstate. It’s all done in client script. I create javascript proxy classes to hit my WCF services, and do everything with jquery. All I’m getting out of ASP.NET is Forms Auth, and maybe some caching.
I’m loving it so far. I’ve been doing pretty serious ASP.NET development for the last 4 or 5 years. I know the page life cycle very well. But it’s time for me to try something new and different. The best part? This new approach is simpler, more direct, and more flexible. “Say what you mean, simply and directly”.
I have a simple app up and running with this stack already, and it’s fantastic. In future posts I’ll be focusing on each individual layer. Expect more soon.
One Trackback
[...] Sam's Code Programming snippets, observations, questions, and news (.NET, C#, SQL, jQuery, javascript, design patterns, NHibernate, Entity Framework, etc) Skip to content About « Entity Framework v4, End to End Application Strategy (Part 1, Intro) [...]