Object-Oriented Design Philosophy • The first step in building an application should be to design a set of classes, each of which has a specific expertise and all of which can work together in useful ways.
Designing Class: the Process 1. Apply design axioms to design classes, their attributes, methods, associations, structures, and protocols. 1.1. Refine and complete the static UML class diagram (object
model) by adding details to that diagram.
1.1.1. Refine attributes. 1.1.2. Design methods and the protocols by utilizing a UML activity diagram to represent the method's algorithm.. 1.1.3. Refine the associations between classes (if required). 1.1.4. Refine the class hierarchy and design with inheritance (if required). 1.2. Iterate and refine again.
Class Visibility • In designing methods or attributes for classes, you are confronted with two issues. – One is the protocol, or interface to the class operations and its visibility; – and how it should be implemented.
Guidelines for Designing Protocols • Good design allows for polymorphism. • Not all protocols should be public, again apply design axioms and corollaries.
Guidelines for Designing Protocols (Con’t) • The following key questions must be answered: – What are the class interfaces and protocols? – What public (external) protocol will be used or what external messages must the system understand?
Questions (Con’t) – What private or protected (internal) protocol will be used or what internal messages or messages from a subclass must the system understand?
Attribute Types • The three basic types of attributes are: – 1. Single-value attributes. – 2. Multiplicity or multivalue attributes. – 3. Reference to another object, or instance connection.
Designing Methods and Protocols (Con’t) – I/O methods. The methods that provide or receive data to or from a device. – Domain specific. The method specific to the application.
Avoiding Design Pitfalls • Keep a careful eye on the class design and make sure that an object's role remains well defined. • If an object loses focus, you need to modify the design. • Apply Corollary 2 (single purpose).