tag:blogger.com,1999:blog-28958520.post1689828032663179404..comments2009-03-31T06:51:51.720-07:00Comments on Pete W's idea book: Architecture confusion with ORMPeter Weissbrodhttp://www.blogger.com/profile/11407295296696177698noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-28958520.post-31202772352526469762009-03-31T06:51:00.000-07:002009-03-31T06:51:00.000-07:00Roelf:Sorry for my late reply:1. Over the past yea...Roelf:<BR/><BR/>Sorry for my late reply:<BR/><BR/>1. Over the past year or so, I've learned that the AcitveRecord pattern is an elegant solution for simple persistence models, and a repository pattern requires more code but proves to be effective when dealing with more complex structures.<BR/><BR/>2. I ALWAYS place my controller and persistence logic underneath interfaces, and use something such as StructureMap, Windsor, or custom service locators to put the pieces together. Once you get the hang of using DI, it is not painful, it enforces loose coupling, and eliminates all of the dependency dilemmas I've mentioned in the article.<BR/><BR/><BR/>Other notes: You can sub-class an AR class within the same table. I usually have an abstract parent, and multiple child classes. I use a discriminator column to determine the class type of any given row.<BR/><BR/>I have some example code if you would like me to send it to you.<BR/>Pay attention to the discriminator attribute on this page:http://www.castleproject.org/activerecord/documentation/trunk/usersguide/typehierarchy.html<BR/><BR/>You CAN make an AR property private, NHibernate supports this. The trick is to make the access modifier for that property set to "field" More information look at the access modifier here:<BR/>http://www.castleproject.org/activerecord/documentation/v1rc1/usersguide/generics.html<BR/><BR/>In terms of validation, I recommend looking at the castle validator component, which allows you to write your own validation method or choose from a stack of existing validators. More information:<BR/>http://hammett.castleproject.org/?p=114<BR/><BR/>again, my apologies on the slow response, if I can help any more, let me knowPeter Weissbrodhttp://www.blogger.com/profile/11407295296696177698noreply@blogger.comtag:blogger.com,1999:blog-28958520.post-18931724186168988952009-03-31T06:40:00.000-07:002009-03-31T06:40:00.000-07:00Ironic?Celebrado, you bring up a very good point, ...Ironic?<BR/><BR/>Celebrado, you bring up a very good point, lumping the controller and view logic together while separating the models is definitely the best solution 99% of the time.<BR/><BR/>Unless of course you need to reuse the controller logic across different view implementations (EG use the same controllers for a web-based version as well as a thick client.) In this case, some DI using an IOC container will solve all of your problems<BR/><BR/>This article was written before MVC.NET, but after Monorail and ruby on rails frameworks gained popularity.Peter Weissbrodhttp://www.blogger.com/profile/11407295296696177698noreply@blogger.comtag:blogger.com,1999:blog-28958520.post-37849468820635347712009-03-30T07:43:00.000-07:002009-03-30T07:43:00.000-07:00(ironic:on)And why not put the controller and the ...(ironic:on)And why not put the controller and the view in the same assembly? (ironic:off)Cerebradohttp://www.blogger.com/profile/02256826719080038028noreply@blogger.comtag:blogger.com,1999:blog-28958520.post-8622678092508796972009-03-23T05:17:00.000-07:002009-03-23T05:17:00.000-07:00Interesting article, thanks for that. Currentyly, ...Interesting article, thanks for that. Currentyly, we have three problems implementing ActiveRecord in the way you descrived last (the free-for-all way):<BR/><BR/>- Inheritance: Thus far I didn't succeed in subclassing AR classes while still saving them in the same DB table. And no, I would not like to create different DB tables for each subclass (I like the free-for-all approach, thank you :) )<BR/><BR/>- Encapsulation: Did you ever try to make an AR property private? In other words, is it possible to save data in the DB that is only managed by the AR class itself? I didn't succeed in this also.<BR/><BR/>- Implementing Business rules (like validation) is also quite hard. Because when you call the Save function of an AR object, it is only performing data-validations, which are quite different then business-validations. And so we have to override every single Save function of AR, 'injecting' our own business-rules.Roelfhttp://www.blogger.com/profile/00071280888664673225noreply@blogger.comtag:blogger.com,1999:blog-28958520.post-24973294550643609592009-02-12T14:29:00.000-08:002009-02-12T14:29:00.000-08:00Yeah.Yeah.Tsukenyohttp://www.blogger.com/profile/05559601320928401567noreply@blogger.com