Active Record business objects
My question: Isn't 'Active Record' an ORM anti-pattern and a serious violation of SRP? Just one reference: http://www.mehdi-khalili.com/orm-anti-patterns-part-1-active-record
Aaron Adams, Nov 05, 2013
It does help,
I had planned to use EF as an ORM for my project. I think the ORM is like anything else, once one has learned it sufficiently, you realize it has its good and bad points. I know many project not follow SOLID principles or best practices, and the software works as initially designed. Of course sometimes rewriting things once requirements/environments change is required. Even when best practices are followed, things must be rewritten -- I guess it is to what extent is the question. Actually I thought that was kind of the point of it all, follow best practices around established patterns, thus enabling more "maintainable" software. Which brings me to the reason I even decided to post the original question. The Active Record pattern does not follow the Single Responsibility Principle, which is the first letter in the SOLID (which are industry leading principles). I wanted to know your take on the Active Record pattern since you're using it in your example code and your site is based off of best patterns and practices. Having said this, I think your product would benefit me even though I'm going to use a different ORM.
Aaron Adams, Nov 06, 2013
Fortunately, the development community embraces free speech and therefore eachDesign Pattern or Practice will have its share of proponents and opponents. My advice would be to familiarize yourself with the more common Patterns and Practices and then decide for yourself which ones are right for you and which ones are not.
As far as Active Record being an anti-pattern, have a look at Ruby on Rails (RoR). It is 100% based on the 'Active Record' pattern.
Here is a list of websites that are built on RoR: Basecamp, Twitter, Scribd, Shopify, Github, Hulu, and thousands more. I suspect that telling these guys that Active Record is an anti-pattern won't make you many friends. Actually, they will not care what you think. It has allowed them to build extremely successful and profitable businesses.
Microsoft has the Entity Framework as its preferred ORM. Unfortunately, it is large, complex, and sometimes inefficient. Just as an example, EF would not be the right tool to handle high-volume websites like stackoverflow.com. Spark offers an alternative ORM (based on Active Record) that is fast, lightweight, and easy to use.
Check it out and see if you like it. I think you will.
All our Design Pattern packages come with a full 60-day money back guarantee,
Hope this helps.
Jack Poorte, Nov 05, 2013