Lesson 6 | Who should own the operations? |
Objective | Define guidelines for allocating responsibility for attributes. |
Who should own the Operations?
The operations in a class description define two types of behavior:
- what an object can do and
- what can be done to the object.
For example, a book can contain pages, chapters, and a table of contents. A book can be read, printed, and sold.
Operation notation
The UML operation notation defines the elements of a class behavior modeled using the syntax:
[visibility] name ([parameter-list]) ':' [return-result] [{properties}]
In addition, UML supports the use of exceptions, pre-conditions, and post-conditions. I will cover the notation elements first, and then these additional operation elements.
Finding behaviors of an object
The sequence (interaction) diagrams provide a method for finding the behaviors of an object that are needed by the current problem domain.
These behaviors are defined as interfaces of the object because other objects need to request them. The sequence diagram approach will provide you with the minimum requirements for navigation between objects.
Other behaviors are internal to an object. Operations may perform any of the following purposes:
- Support the implementation of the interfaces
- Manage the state of the object
- Maintain the attribute values that describe the object
- Allow the object to maintain relationships with other objects
The key to assigning behaviors to an object
Again, the key to assigning behaviors to an object is responsibility.
- What is the responsibility of the object?
- Are the behaviors required to fulfill the object's responsibility?