views:

131

answers:

1

Do you try to keep the Distance from main sequence low for every assembly? What about assemblies that contains only Business Objects definitions? Is it possible to keep them away from Zone of Pain? Types in such assemblies are usually used by other assemblies and are rather concrete. How to handle such situation?

+4  A: 

I believe the objective of {keeping the "distance from main sequence" low} is based on the Law of Demeter. Following this rule helps make your code easier to understand and easier to unit test. By using Business Objects that are mere data containers, you are exposing more state than may be necessary and breaking rules of encapsulation.

However, as Fowler points out in this article, "While method chains are a smell, the opposite problem of middle men objects bloated with forwarding methods is also a smell. (I've always felt I'd be more comfortable with the Law of Demeter if it were called the Suggestion of Demeter.)"

I think the value of such basic Business Objects can be useful if you only want to pass around "what" the object contains, such as how they are used as Data Transfer Objects. However, it's probably important to distiguish your true Business Objects from your empty Data Transfer Objects. I would assume real Business Objects should also contain behavior along with the data they encapsulate.

Chris Melinn