Is it better to create Model classes or stick with generic database utility class? *

Question

We have a simple utility class in-house for our database calls (a light wrapper around ADO.NET), but I am thinking of creating classes for each database/object. Would it be smart thing to do so, or would it only benefit if we were using the full MVC framework for ASP.NET?

So we have this:

SQLWrapper.GetRecordset(connstr-alias, sql-statement, parameters);
SQLWrapper.GetDataset(connstr-alias, sql-statement, parameters);
SQLWrapper.Execute(connstr-alias, sql-statement, parameters);

Thinking of doing this:

Person p = Person.get(id);
p.fname = "jon";
p.lname = "smith";
p.Save();

or for a new record -

Person p = new Person();
p.fname = "Jon";
p.lname = "Smith";
p.Save();
p.Delete();

Would this be smart, or would it be overkill? I can see the benefit for reuse, changing database, and maintenance/readability.

Answer

This question is loaded, data driven design vs domain driven design. For any application that has a good amount of behavior, then domain driven design should be preferred. Reporting, or utility applications tend to work better (or are quicker to develop) with data driven design.

What you're asking is "should my company make a fundamental shift in how we design our code". As a domain-freak, my gut reaction is to scream yes. However, by the simple nature of your question, I'm not sure you fully understand the scope of the change you are proposing. I think you should talk more to your team about it.

Get some literature, such as Evan's DDD book, or the free foundations ebook, and then you'll be in a better position to judge which direction you should go.

< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/2778/" >Is it better to create Model classes or stick with generic database utility class?< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment