Last post Dec 19, 2009 01:25 PM by aquaren
Dec 19, 2009 11:52 AM|justsomename|LINK
1) As far as I’m aware, each domain object instance ( at BLL layer ) should completely represent an element of the domain ( an employee, book, car etc ).
So what is an advantage of having two types of domain objects, say one type representing a particular forum and other type representing a thread(s) in that forum, over having a single domain object type representing both a forum and thread(s) inside this
Another example: what’s an advantage of having two types of domain objects, one representing an instance of a car, and other representing an instance of a bus, instead of having a single type of a domain object representing both a car and a bus?
Dec 19, 2009 01:25 PM|Aquaren|LINK
There are entire books written about this very subject so answering it in a paragraph or two is going to be tough, but here goes...
Objects are about behavior. The behavior and data that supports that behavior (properties) of, as in your first example, a forum are quite different from the behavior and properties of a thread in that forum. The behavior and properties of a message in that
thread is different from the thread itself. The objects each have a different set of concerns, just as each object within a layer has a definite set of concerns. By keeping a definite separation or boundary of those concerns, we create code that is more testable,
flexible, maintainable, and enduring.
As for your second example, a bus and a car do have similar or shared behaviors and properties (wheels, doors, steering wheel, transmission, etc.), but you would not use the same transmission in a or engine in a car as you would in a bus.
I recommend that you spend some time looking at the SOLID design principles to get a better idea of how they play a role is this as well:
Object oriented design