Engineering 5895: Software Design 9/11/01Class Diagrams 1
Engineering 5895: Software Design 9/11/01Class Diagrams 2 Perspectives Conceptual classes represent concepts in a domain software (& language) independent Specification classes represent interfaces (or types) Implementation full classes automatic code generation
Engineering 5895: Software Design 9/11/01Class Diagrams 3 Interface vs Implementation Not well distinguished by current OOP languages Classes (particularly in C++) combine the two Design Rule #1 Program to the interface, not the implementation
Engineering 5895: Software Design 9/11/01Class Diagrams 4 A Class Diagram
Engineering 5895: Software Design 9/11/01Class Diagrams 5 A Class Diagram Associations
Engineering 5895: Software Design 9/11/01Class Diagrams 6 Associations Relationships between instances of classes Conceptual perspective conceptual relation Specification perspective responsibility Implementation imply specifics (e.g. pointers)
Engineering 5895: Software Design 9/11/01Class Diagrams 7 A Class Diagram Generalization
Engineering 5895: Software Design 9/11/01Class Diagrams 8 A Class Diagram Abstract class represented by italicised name
Engineering 5895: Software Design 9/11/01Class Diagrams 9 Multiplicities Mandatory At each end * 1..* 1,3,9..11 Multiplicities
Engineering 5895: Software Design 9/11/01Class Diagrams 10 Multiplicities
Engineering 5895: Software Design 9/11/01Class Diagrams 11 Role Names
Engineering 5895: Software Design 9/11/01Class Diagrams 12 Role Names Are optional May go at either (or both) end(s) Alternatively, association itself may be named Bleah! Only name roles when it adds clarity
Engineering 5895: Software Design 9/11/01Class Diagrams 13 Role Names
Engineering 5895: Software Design 9/11/01Class Diagrams 14 Multiple associations Second association saying department has one head who is a professor (and prof can only be head of one department)
Engineering 5895: Software Design 9/11/01Class Diagrams 15 Directed associations New association is directed, meaning it can only be navigated from department to prof. E.g. department is supposed to know who its head is but prof doesn't have to know he/she is head.
Engineering 5895: Software Design 9/11/01Class Diagrams 16 Direction No arrowheads means either directionality is unspecified navigability is in both directions I prefer unspecified (except, perhaps in implementation perspective)
Engineering 5895: Software Design 9/11/01Class Diagrams 17 Attributes What is difference between attribute and association? Often none At implementation, association will often imply a pointer from one class to the other Use attributes for primitive, wholly contained data (integers, strings)