CH - 4 Object Oriented Design
CH - 4 Object Oriented Design
Chapter Four
• It is highly iterated
Unity University 2
Cont.
Design Artifacts And Their Relationship
Unity University 3
Layering your models – Class Type Architecture
Unity University 5
Cont.
1. Interface classes.
Unity University 7
Cont.
3. Process classes
4. Persistence classes.
Unity University 9
Cont.
• Collaboration between classes is allowed within a layer;
UI classes UI classes and business/domain classes can send messages to other
business/domain classes.
Domain classes may send messages to persistence classes, but not to interface
classes.
Unity University 11
Cont.
A simple example of an e-commerce system
Domain Classes:
Unity University 12
Cont.
A simple example of an e-commerce system
Process Classes:
Unity University 13
Cont.
A simple example of an e-commerce system
System Classes:
• The Logger class manages logging and error handling in the system,
providing functionality to record and track system events.
•.
A simple example of an e-commerce system Cont.
Persistence Classes:
Unity University 15
A simple example of an e-commerce system Cont.
Interface Classes:
Unity University 16
Class Modeling
Unity University 18
Cont.
Modeling Methods during Design
Visibility
How a method is accessed by objects
To reduce coupling within your system, the general rule of thumb
is to be as restrictive as possible when setting the visibility of a
method
A method doesn’t have to be public, then make it protected, if it doesn’t have to be
protected make it private
Unity University 19
Cont.
Modeling Methods during Design
Visibility
Unity University 20
Cont.
Modeling Methods during Design
Naming
Use a full description, using mixed case with the first letter of any non
initial word capitalized
“methodName()”
Unity University 21
Cont.
Modeling Methods during Design
Student
name
phoneNumber
emailAddress
studentNumber
averageMark
+isEligible(name:string, studentNumber:StudentNumber):boolean
+Student(studentNumber: StudentNumber ): Student<<constructor>>
+ getCoursesTaken(): Vector
+ purchaseParkingPass()
+getAverageMark(): long
- setAverageMark(newAverageMark:long)
Unity University 22
Cont.
Modeling Attributes during design
Initial value (optional). The initial value (if any) for an attribute
should also be indicated.
Unity University 23
Cont.
Modeling Attributes during Design
Unity University 24
Techniques for Attributes Cont.
• Assign private visibility to all attributes;
• Update attributes only in their setter methods;
• Directly access attributes only in their getter methods;
• Always invoke a setter method for an attribute to update its value, even
within the class where it is defined;
• Always invoke a getter method for an attribute to obtain its value, even
within the class where it is defined;
• Implement simple validation logic for an attribute in its setter method;
• Implement complex validation logic in separate methods; and
• Apply lazy initialization in getter methods for attributes that are rarely
needed Unity University 25
Modeling Association and Dependencies Cont.
• Model (don’t) the scaffolding for your associations
• Multiplicity must be shown
• Question multiplicities involving minimums and maximums
• Associations and dependencies are inherited
• Collaboration goes hand in hand with relationships
• Model a unidirectional association when collaboration is
only one way
• Model a dependency when one of the instances is transient
• Model a dependency when an object interacts only with a
class, but not the instance
Unity University 26
State Chart/Machine Modeling
Unity University 27
Cont.
Unity University 30
Cont.
Unity University 31
Cont.
Drawing State Machine Diagrams
• Identify the creation state and whether any final states exist.
don't forget about recursive transitions that lead to the same state
Unity University 32
Collaboration/ Communication Diagrams
• The same notation for classes and objects used on UML sequence
diagrams are used .
[sequenceNumber:] methodName(parameters)
Unity University
[: returnValue]
34
Cont.
Unity University 35
Cont.
Unity University 36
Cont.
Drawing Communication Diagrams
• Identify
The scope of the diagram
The objects
The relationships between the objects
The messages passed between the objects
Unity University 37
Component Modeling
• The component model illustrates the software components that will be
used to build the system.
Unity University 39
UML 1.x component diagram for the university. Cont.
Unity University 40
Deployment Diagram
Unity University 41
deployment diagram for the university information system Cont.
Unity University 42
deployment diagram for the university information system Cont.
Unity University 43
Relational Persistence Modeling
Unity University 44
Cont.
Rules to transform/convert class diagrams to the relational database:
2. Inheritance:
Unity University 45
Cont.
Rules to transform/convert class diagrams to the relational database:
Unity University 46
Cont.
• Rules to transform/convert class diagrams to the relational database:
3.Mapping relationship:
Unity University 47
Cont.
• Rules to transform/convert class diagrams to the relational database:
Unity University 48
User Interface Design
• A fundamental reality of application development is that the user
interface is the system to the users.
Unity University 49
Cont.
The structure principle. concerned with your overall user interface
architecture. Putting related things together and separating unrelated
things, differentiating dissimilar things and making similar things
resemble one another.
The visibility principle. should keep all needed options and materials
for a given task visible without distracting the user with extraneous or
redundant information.
Unity University 50
Cont.
The feedback principle. should keep users informed of actions or
interpretations, changes of state or condition, and errors or exceptions
The reuse principle. Your design should reuse internal and external
components and behaviors, maintaining consistency with purpose rather
than merely arbitrary consistency, thus reducing the need for users to
rethink and remember.
Unity University 51
Cont.
Techniques for improving your UID
Unity University 53