uml class diagrams
play

UML Class Diagrams Steven Zeil February 25, 2013 UML Class - PowerPoint PPT Presentation

UML Class Diagrams UML Class Diagrams Steven Zeil February 25, 2013 UML Class Diagrams Outline Class Diagrams 1 A Class, in Isolation 2 Attributes Operations Generalization Relationships 3 Associations 4 Naming Your


  1. UML Class Diagrams UML Class Diagrams Steven Zeil February 25, 2013 ✓ �

  2. UML Class Diagrams Outline Class Diagrams 1 A Class, in Isolation 2 Attributes Operations Generalization Relationships 3 Associations 4 Naming Your Relationships Multiplicity Navigability Specialized Associations 5 Aggregation Composition Qualification Dependency Other Class Diagram Elements 6 ✓ � Drawing UML Class Diagrams 7

  3. UML Class Diagrams UML Class Relationship Diagrams Next we turn to more formal documentation that you can expect to show outside your team and probably to retain for the lifetime of the project. We will employ UML notation for this. UML notation has quickly become an industry standard with applications outside of "traditional" software engineering: e.g., DBs ✓ �

  4. UML Class Diagrams UML Diagrams UML provides a number of different diagrams use case diagrams class diagrams interaction diagrams sequence diagrams collaboration diagrams package diagrams state diagrams activity diagrams deployment diagrams We’ll look eventually at the ones shown in italics , starting with class diagrams. ✓ �

  5. UML Class Diagrams Diagramming in Context The diagrams are part of an overall documentation strategy We don’t draw diagrams to stand by themselves. Instead, like the diagrams that appear in, say, your textbook, each one is intended as part of a larger document, much of which will be explanatory text. Furthermore, we draw diagrams for the same reasons we write sentences and paragraphs, to communicate some specific idea. If a diagram is too complicated to be understood, it’s no more use than a sentence that is too complicated to be understood. If a diagram is too vague to convey any definite meaning, it has no more value than an equally vague sentence. The success or failure of a diagram lies entirely in its ability to communicate what the author intended. The diagrams are actually the representation of a formal "language" and are expected to make statements that are meaningful according to the rules of that language. ✓ �

  6. UML Class Diagrams Class Diagrams Outline I Class Diagrams 1 A Class, in Isolation 2 Attributes Operations Generalization Relationships 3 Associations 4 Naming Your Relationships Multiplicity Navigability Specialized Associations 5 Aggregation Composition Qualification Dependency ✓ �

  7. UML Class Diagrams Class Diagrams Outline II Other Class Diagram Elements 6 Drawing UML Class Diagrams 7 ✓ �

  8. UML Class Diagrams Class Diagrams Class Diagrams A class diagram describes the types of objects in the system and selected static relationships among them. The relationships can be generalization (e.g., a Librarian is a specialized kind of Library Staff) association (e.g., a Patron may have up to 20 Publications checked out at one time) ✓ �

  9. UML Class Diagrams Class Diagrams Perspectives A diagram can be interpreted from various perspectives: Conceptual : represents the concepts in the domain at most loosely related to the software classes that will implement them Specification : focus is on the interfaces of ADTs in the software Implementation : describes how classes will implement their interfaces The perspective affects the amount of detail to be supplied and the kinds of relationships worth presenting. ✓ �

  10. UML Class Diagrams A Class, in Isolation Outline I Class Diagrams 1 A Class, in Isolation 2 Attributes Operations Generalization Relationships 3 Associations 4 Naming Your Relationships Multiplicity Navigability Specialized Associations 5 Aggregation Composition Qualification Dependency ✓ �

  11. UML Class Diagrams A Class, in Isolation Outline II Other Class Diagram Elements 6 Drawing UML Class Diagrams 7 ✓ �

  12. UML Class Diagrams A Class, in Isolation A Class, in Isolation A class can be diagrammed as Class Name Class Name attributes operations() You would use the simpler form in a conceptual perspective, or if the attributes and operations of the class were not relevant to the point of your diagram in specification or implementation perspectives. ✓ �

  13. UML Class Diagrams A Class, in Isolation Even an Empty Section has Meaning Note that these are not equivalent: Class Name Class Name The left diagram says that we aren’t discussing the attributes and operations. The right diagram says that this class has no relevant attributes and operations. ✓ �

  14. UML Class Diagrams A Class, in Isolation Attributes Attributes Attributes are given as visibility name: type = defaultValue Only the name is required. The others may be added when relevant: visibility: + (public), # (protected), or - (private) Only for implementation perspective. When you are only talking about concepts or interface specifications, the idea of a "private" anything is irrelevant. Cell Cell Cell -expression: Expression = null -value: Value = null expression expression: Expression Cell +evaluate(SpreadSheet) value value: Value +getFormula(): Expression evaluate the expr() evaluate(SpreadSheet) +setFormula(Expression) +getValue(): Value Conceptual Specification Implementation Attributes are usually single values. Ones that take multiple values (lists, etc.) are generally represented using associations. ✓ �

  15. UML Class Diagrams A Class, in Isolation Operations Operations Operations are given as visibility name (parameterlist) : return-type Again, the amount of detail depends on the perspective (and on how much has actually been decided) Cell Cell Cell -expression: Expression = null -value: Value = null expression expression: Expression Cell +evaluate(SpreadSheet) value value: Value +getFormula(): Expression evaluate the expr() evaluate(SpreadSheet) +setFormula(Expression) +getValue(): Value Conceptual Specification Implementation ✓ �

  16. UML Class Diagrams Generalization Relationships Outline I Class Diagrams 1 A Class, in Isolation 2 Attributes Operations Generalization Relationships 3 Associations 4 Naming Your Relationships Multiplicity Navigability Specialized Associations 5 Aggregation Composition Qualification Dependency ✓ �

  17. UML Class Diagrams Generalization Relationships Outline II Other Class Diagram Elements 6 Drawing UML Class Diagrams 7 ✓ �

  18. UML Class Diagrams Generalization Relationships Generalization Relationships A class (the " subtype ") is considered to be a specialized form of another class (the "supertype") or, alternatively, the supertype is a generalization of the subtype if conceptual: all instances of the subtype are also instances of the supertype specification: the interface of the subtype contains all elements of the interface of the supertype The subtype’s interface is said to conform to the interface of the supertype implementation: the subtype inherits all attributes and operations of the supertype ✓ �

  19. UML Class Diagrams Generalization Relationships Diagramming Generalization The UML symbol for this relationship is an arrow with an unfilled, triangular head. Read this arrow as "is a specialization of", "is a kind of", or "is a". (The Publication latter can be a bit ambiguous title however, as we might also say that date of publication Webster’s Dictionary "is a" Book, but get content(): text that’s not a generalization relationship. We infer from the relationship that Magazine Book books and magazines have titles and volume isbn dates of publication and that we can number get their content. However, not all publications have ISBNs. ✓ �

  20. UML Class Diagrams Generalization Relationships Multiple Specializations E-Book HardCopy format pagecount: int Some classes may participate in Publication multiple generalization relationships. title The arrows are grouped together to date of publication indicate related, mutually exclusive, get content(): text divisions: Magazine Book volume isbn number ✓ �

  21. UML Class Diagrams Associations Outline I Class Diagrams 1 A Class, in Isolation 2 Attributes Operations Generalization Relationships 3 Associations 4 Naming Your Relationships Multiplicity Navigability Specialized Associations 5 Aggregation Composition Qualification Dependency ✓ �

  22. UML Class Diagrams Associations Outline II Other Class Diagram Elements 6 Drawing UML Class Diagrams 7 ✓ �

  23. UML Class Diagrams Associations Associations An association is any kind of relationship between instances of classes. Generalization is not an association because it is a relation between the classes themselves, not between their instances (objects). In a conceptual perspective, associations represent general relationships. In a specification perspective, associations often denote responsibilities. ✓ �

  24. UML Class Diagrams Associations Diagramming Associations Associations are shown as lines SpreadSheet Cell connecting classes. Plain associations like these are not particularly Expression Value useful. This one tells us, for example, that some spreadsheets have some kind of relationship with some cells. Only in very rare circumstances would that be a useful insight into the author’s understanding of the spreadsheet world. ✓ �

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend