I primarily develop web-based, business applications so I use a pretty common 3-layer approach: UI, Business Logic, and Data Access. Also, because of this background, the data-access/presistence aspect of my architecture has received the most attention.
I have been using a generic Data Access layer (a meta-data driven object/relation mapper). The calls to data-access api are only executed in "manager" classes of the business logic layer, and never from the UI layer.
Classes in the BLL are grouped into two distinct types. The first group are what I would call domain-logic entities (customers, orders, producsts, etc) which have very limited responsibility pertaining to what they "are", and know about their parent and child classes when there are heirarchies in the domain. Classes of this group almost always mimic the database schema. Notably, these classes do not talk directly to the DAL - their persistence is handled by persistence-management classes.
The second "type" of class in the BLL are more functional classes which manage the persistence (and other processing) of the entity classes by providing a simple interface for the UI layer.
This is all pretty standard, I think. The primary deviance I think you will see when comparing the architecture I describe with others models, is that in my case my domain-entity classes do not manage their own persistence. For instance, you may see things like:
Code:
User u = User.GetNewUser();
//do stuff with u
u.Save();
but I prefer something like this:
Code:
UserManager manager = BLL.UserManager.GetInstance();
User u = manager.GetUser();
//do stuff with u
manager.Save(u);
And the reason is that often the processing and persistence that goes on for the entities requires several differnet obejcts of different types to participate. I prefer a centralized manager to handle the transactions and so forth that are needed.
Thanks. Needed to get that in writing... ;-)
![[pipe] [pipe] [pipe]](/data/assets/smilies/pipe.gif)
Share your knowledge! -