views:

694

answers:

6

You find alot of hype around frameworks like The Entity Framework, and other frameworks like it. I wrote a data access layer and business object model layer of my own for a recent project and I seem to like it more than what I have read about the Entity Framework. Is it "better" to conform to a framework rather than writing one yourself?

+3  A: 

Writing a data access layer is like driving a nail in your forehead. Its a great challenge, but halfway through you figure out its a stupid idea.

Its always better to leverage (good) existing code than trying to reinvent the wheel every time.

Will
+2  A: 

I prefer to write custom DALs and BOLs. This approach takes longer but it gives me complete control over what is happening and when. As long as time permits and best practices are known and followed I see very few reasons why someone should not write their own.

DaveK
+16  A: 

It's always a question of costs vs benefits. In vanilla applications, the DAL is extremely simple and there is no added value of using your own (beside the learning curve of the framework, that is always harder than expected).

However, many applications end with custom scenarios (you don't want to retrieve every field of an object at first, ...) where using the Framework may end in adding overhead (and headaches).

I personally use NHibernate as much as possible, because this is a great framework. But for every hour I have gained using it, I may have lost half an hour trying to circumvent it for exotic scenarios.

My take is "try to use a framework when needed, but don't expect it to tailor your every need". Sometimes the cost can be very high in the end.

Luk
I don't think you can put enough emphasis on this point.
Mitchel Sellers
+3  A: 

When working projects that were primarily using stored procedures on the back end I've preferred to use a DAL generator designed in-house. That way we can control everything about the code while avoiding hand-coding the repetitive stuff.

marc
+2  A: 

Don´t make the wheel again. if you want to write something custom why don´t you collaborate with an open sourde project?

Mariano
+2  A: 

I love Will's comparison to driving a nail in with your forehead. Ha ha. Really, I could not agree more.

Code generation is a time-saving technique that helps developers do better, more creative, and useful work by reducing redundant hand-coding. In this world of increasingly code-intensive frameworks, the value of replacing laborious hand-coding with code generation is acute and, thus, its popularity is increasing.

Do NOT write something buggy, inefficient, and specialized. Especially when reliable, efficient, and generic tools are available. Many of these technologies are free and/or open source.

Some of the template driven solutions offer you some decent wins in being able to regenerate a DAL after schema changes, over others (like hand written stored procedures). It's worth weighing up the productivity gains vs. the disadvantages.

Take a serious look at .netTiers, LLBLGen Pro, CodeBreeze, Linq to SQL, Entity Framework, or some other tool.

Bobby Ortiz