Hi guys,
I just got back from building a project on Monorail using ActiveRecord, and I've noticed quite a difference in their approach vs ours. ActiveRecord is built on the NHibernate stack, and there is little duplicate code in NHiberate vs NetTiers. Granted, NHibernate isn't auto-generated, but I think we could reduce our DRY problem greatly without sacrificing the features that make NetTiers so useful.
For example, for each Service class that is generated, NetTiers creates a partial class file with a generated base class file. All of this code is redundant and duplicated. If one wanted to modify say, the way in which SecurityContext is implemented, they'd have to do it in every class. The same is true across the entire system. Providers, Helpers, Entities, Validation, etc.
I'm wondering what are the thoughts in the community regarding this?
For example, if you have a CustomerService class, and open up the generated CustomerServiceBase partial class, nearly all of that code in there could be moved into a more comprehensive generic ServiceBase<T> class. Then, you can eliminate the many of the partial classes, and the CustomerServiceBase class altogether. CustomerService can inherit from ServiceBase<T>, and still contain all the custom logic that the developer doesn't want regenerated. As far as I've seen, this refactoring applies throughout most of the system. Instead of having hard-coded provider classes (such as dataProvider.CustomerProvider.GetPaged() etc, the ServiceBase<T> can just call ProviderRepository<T>, passing in customer. Another area where this would reduce the code is in the CustomerFilterBuilder classes, etc. These are simply inheriting from SqlFilterBuilder<TColumn> anyway, so it is ripe for refactoring. I would estimate that one could reduce the codesize of the framework by >60% or even more. This would allow for easier refactoring of upcoming feature requests, such as the integration of popular DI frameworks, or the new Validation/Policy Injection frameworks from MS. As it stands now, refactoring is a bit of a daunting task.
Thoughts anyone?
Scott Klarenbach
PointyHat Software
www.pointyhat.ca
_______________________________________
To iterate is human; to recurse, divine