Q&A on UML Distilled
Articles by Bala Paranj
Question 1:
In UML Distilled, Fowler says "One of the strengths of object-oriented development is that you can vary the interfaces of classes independently of the implementation." How do we accomplish this?
Answer:
In order to vary the interfaces of classes independently of the implementation you need to decouple the abstraction from its implementation.
This applies the basic principle of Design Patterns: Separate the things that vary and encapsulate it behind an interface.
This is exactly what the Bridge Pattern does.
Intent: Decouple an abstraction from its implementation so that the two can vary independently.
Example: Java GUI API, it allows the GUI components to vary independently of the platform it runs on.
Component in one hierarchy, which is implemented by different types of GUI components, and the parallel hierarchy consists of ComponentPeer and its implementation for different platforms.
Question 2:
Refer pg 58 UML Distilled 2 ed
"The difference occurs at the specification and implementation levels. Attributes imply navigability from the type to the attribute only. Furthermore, it is implied that the type contains solely its own copy of the attribute object, implying that any type used as an attribute has value rather than reference semantics."
Can you explain this in simpler language with an example.
Answer:
He is explaining the difference between an attribute and an association.
By saying "Attributes imply navigability from the type to the attribute only." means if you have a Person class with a birthday Date attribute, then Date attribute implies navigability from the Person class to the Date attribute only (note the difference from association). Also every Person class has its own copy of birthday even if it is the same (note the difference from reference object). In other words the Person can answer the question: When is your birthday?
OOAD skills for the real world projects
Study Guide - Object Oriented Analysis and Design with UML