OOPortal OOPortal


Model Refinement   «Prev  Next»
Lesson 5Who should own the attributes?
ObjectiveDefine Guidelines for allocating Responsibility to Attributes

Define Guidelines for allocating Responsibility to Attributes

One of the primary goals of modeling is to complete the class diagram to the extent that you can generate the complete class declarations for all the problem domain resources. The class declaration includes the attributes and operations that define the class of objects.

What information is really needed?

Attributes are just pieces of information about an object. The problem is deciding what information is really needed to define an object. Early in this course, you learned the concept of abstraction, that is, representing a real object in a useful manner for a specific problem. Creating a useful definition depends entirely on the context in which the object will be used, the level of detail that you need for the current problem, and the time frame of the problem.

Guidelines for assigning attributes

In addition, I offer these guidelines for assigning attributes to a class of objects:
  1. The information should describe what the object is. If you had to define the object to someone who had never seen it, what information would you use to describe it? Remember always to be aware of cohesion and coupling when defining an object. If you find that you have to add a lot of loosely related information to describe the entity, then you might want to split up the class to improve cohesion.
  2. The information may describe the current condition of the object. Within a system, an object can experience any number of changes. A complete definition of the object should clearly describe its current state or condition, for example, a bank account may be open, closed, or overdrawn. Try to find characteristics of the objects that define their state before you simply add a "status" attribute. You will have to figure out how to set the status value anyway, so try to determine what properties of the object define its state.