serenarules — 2011-11-06T19:56:31-05:00 — #1
Out of recent frustrations with an overly complex domain model, one that was impossible to create routes for, and issues with persistence mapping, an interesting realization was born. I threw caution to the wind and duplicated my current project (real client) using SqlClient instead of EntityFramwork or NHibernate. I scrapped all the domain objects, the mapping classes, the configuration classes, factory classes, dependency injection, automapper and several other things. Instead, I performed simple SqlClient code right in the mvc actions that needed them. I used SqlDataReaders to push data right onto the view models and pushed SqlParameters into the SqlCommand right from incoming view models. The result was extremely fast. Faster than I think any app written by me recently has ever been. Granted, there was a bit of code duplication from action to action, but you know what? Compared to everything I sacked to write this, there was still far less code overall. What was surprising is that it ran more efficiently than before. I know I will probably get trashed for this, but everything was so simple and elegant, I wonder why I ever moved to something else. Honestly, I am beginning to believe that a lot of what people tout as the correct way to do things (read DDD/TDD/ORM here) are extremely overrated. Just my thoughts at this point.
imaginekitty — 2011-11-06T20:14:48-05:00 — #2
The way I understand it is that DDD/TDD are more important when working with a team with distinct jobs in the process. This is something I never do so I very much agree with you.
ORM = convenience to me. With or without is of no consequence.
I'm jumping ship to Ruby on Rails anyway.
matt_daly — 2011-11-09T17:00:33-05:00 — #3
Raven or Mongo are the way to go. That or the jumping ship idea :weee:
wwb_99 — 2011-11-09T21:52:53-05:00 — #4
Don't know about mongo -- just doesn't feel safe enough for my data. But RavenDb or CouchDb are great options for the right data shapes and application types.
Using straight ADO.NET is a reasonable option for apps of the right shape and nature. I really wouldn't want it strewn about my controllers but rather in a middleware layer of some sort, if for nothing else than for non-web or other website use cases.
serenarules — 2011-11-10T00:21:07-05:00 — #5
Eh, well I wouldn't put it in the controller for real. I've adopted a scaled down version of CQRS, without the Event Sourcing component, so the only place you'll see sqlclient is in a CommandHandler or a QueryHandler.