1 / 54

Introduction to Unified Modelling Language (UML) (part 2 Class diagram, Associations)

Introduction to Unified Modelling Language (UML) (part 2 Class diagram, Associations). Objects. What are Objects “ a discrete entity with a well-defined boundary that encapsulates state and behaviour ; an instance of a class” UML Reference Manual, 2nd Edition-2004 Observations

nantai
Télécharger la présentation

Introduction to Unified Modelling Language (UML) (part 2 Class diagram, Associations)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction toUnified Modelling Language (UML)(part 2 Class diagram, Associations)

  2. Objects • What are Objects • “a discrete entity with a well-defined boundary that encapsulates state and behaviour; • an instance of a class” UML Reference Manual, 2nd Edition-2004 • Observations • an instance of a class • state is maintained in fields • behaviour is implemented via methods • every object is uniquely identified

  3. UML Object Notation

  4. Classes • What are Classes • “the descriptor for a set of objects that share the same attributes, operations, methods, relationships, and behaviour” UML Reference Manual, 2nd Edition-2004 • template for objects with similar features

  5. UML Class Notation

  6. UML Class Notation

  7. How Much to Show? • Scenarios • scenario 1: inter-class relationship • scenario 2: behaviour of a class or classes • scenario 3: entity classes representing data entities

  8. How Much to Show? • Scenarios • scenario 1: inter-class relationship • class boxes are probably enough with name compartment only • scenario 2: behaviour of a class or classes • class boxes with name & operations compartment

  9. Analysis Classes • What is an Analysis Class? • represents an important concept of the problem domain • maps on to real-world concepts • an attempt to capture the big picture

  10. Analysis Classes

  11. Analysis Classes • Observations • name reflects the intent of abstraction • focus clearly defined/understood • small & well defined set of responsibilities • high cohesion & low coupling

  12. Classes • The three class types in the Unified Process are • Entity classes • Boundary classes • Control classes • UML notation

  13. Entity Classes • An entity class models information that is long lived • Examples: • Account Class in a banking information system • Mortgage Class and Investment Class in the information system • Instances of all these classes remain in the information system for years

  14. Boundary Classes • A boundary class models the interaction between the information system and its actors • Boundary classes are generally associated with input and output • Examples: • Sales Report Class in the E-Commerce information system • Mortgage Listing Class and Investment Listing Class in the information system

  15. Control Classes • A control class models complex computations and algorithms • Examples: • Compute GPA Student Class, in the PSU information system

  16. Stereotypes • UML notation for these three types of classes • These are stereotypes (extensions of UML) • UML allows us to define additional constructs that are not part of UML but which we need in order to model a system accurately

  17. The Unified Process and Classes • The Unified Process does not describe how classes are extracted • Users of the Unified Process are expected to have a background in object-oriented analysis and design • We temporarily suspend this discussion of the Unified Process to explain how classes are extracted, and then return to the Unified Process

  18. Extracting Entity Classes • Entity class extraction consists of three steps that are carried out iteratively and incrementally: • Functional modeling • Present scenarios of all the use cases (a scenario is an instance of a use case) • Class modeling • Determine the entity classes and their attributes • Determine the interrelationships and interactions between the entity classes • Present this information in the form of a class diagram • Dynamic modeling • Determine the operations performed by or to each entity class • Present this information in the form of a statechart

  19. Flowchart for Extracting Entity Classes

  20. Initial Class Diagram: Painting System Case Study • The second step in extracting the entity classes is class modeling • The aim of this step is to extract the entity classes, determine their interrelationships, and find their attributes • Usually, the best way to begin this step is to use the two-stage noun extraction method • Stage 1: Describe the information system in a single paragraph • Stage 2: Identify the nouns in this paragraph, then select the entity classes from those nouns

  21. Noun Extraction: Painting System Case Study • Stage 1: Describe the information system in one paragraph: • Reports are to be generated in order to improve the effectiveness of the decision-making process for buying works of art. The reports contain buying and selling information about paintings, which are classified as masterpieces, masterworks, and other paintings

  22. Noun Extraction: Painting System (contd) • Stage 2: Identify the nouns in this paragraph • Reports are to be generated in order to improve the effectiveness of the decision-making process for buyingworks of art. The reports contain buying and sellinginformation about paintings, which are classified as masterpieces, masterworks, and other paintings • The nouns are report, effectiveness, process, buying, work of art, selling, information, painting, masterpiece, and masterwork

  23. Noun Extraction: Painting System (contd) • effectiveness, process and information are abstract nouns and are therefore unlikely to be entity classes • Abstract nouns identify things that have no physical existence • Nouns buying and selling are derived from the verbs “buy” and “sell” • They will probably be operations of some class

  24. Noun Extraction: Painting System (contd) • Noun report is unlikely to be an entity class, because a report is not long lived • A report is much more likely to be a boundary class • Noun work of art is just a synonym for painting

  25. First Iteration of the Initial Class Diagram • This leaves four candidate entity classes: • Painting Class, Masterpiece Class, Masterwork Class, and Other Painting Class

  26. Second Iteration of the Initial Class Diagram • Consider the interrelationships between the entity classes • A masterpiece is a specific type of painting, and so is a masterwork and an “other painting” • PaintingClass is therefore the base class • Masterpiece Class, Masterwork Class, and Other Painting Class are subclasses of that base class

  27. Second Iteration of Initial Class Diagram (contd)

  28. Third Iteration of the Initial Class Diagram • The class diagram does not reflect aspects of the pricing algorithm • When dealing with a masterwork • “The information system first computes the maximum purchase price as if it were a masterpiece by the same artist”

  29. Third Iteration of the Initial Class Diagram (contd) • That is, a masterwork has to have all the attributes of a masterpiece (so that its maximum purchase price can be computed as if it were a masterpiece) and, in addition, it may have attributes of its own • This is modeled in the next slide

  30. Third Iteration of the Initial Class Diagram (contd)

  31. Fourth Iteration of the Initial Class Diagram • Another aspect of the pricing algorithm that is not reflected in the current class diagram is • “The information system computes the coefficient of similarity between each painting for which there is an auction record and the painting under consideration for purchase”

  32. Fourth Iteration of the Initial Class Diagram (contd) • Auctioned Painting Class is needed to make these comparisons • An auctioned painting must be a subclass of PaintingClass • But a painting previously been sold at an auction somewhere in the world has nothing to do with paintings currently on display for sale in Osbert’s gallery

  33. Fourth Iteration of the Initial Class Diagram (contd)

  34. Fourth Iteration of the Initial Class Diagram (contd) • An instance of PaintingClass is either • A painting that Osbert has bought (an instance of Gallery Painting Class), or • A painting sold at some auction (an instance of Auctioned Painting Class)

  35. Initial Class Diagram: Painting System Case Study • Why was the first iteration of the class diagram so inadequate? • The Painting System case study appears to be a straightforward data-processing application • The one-paragraph description correctly did not incorporate the pricing algorithm • Unfortunately, the algorithmic details turned out to be critical to the class diagram

  36. Initial Class Diagram: Painting System (contd) • The first iteration of the class diagram was no good • However, repeated iteration and incrementation led to a reasonable class diagram • This demonstrates the power of the iterative and incremental approach

  37. Initial Class Diagram (contd) • Finally, we add the attributes of each class to the class diagram • the result is shown on the next slide • The empty rectangle at the bottom of each box will later be filled with the operations of that class

  38. Fifth Iteration of the Initial Class Diagram (contd)

  39. Fifth Iteration of the Initial Class Diagram (contd)

  40. Done with the Painting System case study • Still the dynamic modeling – later

  41. Design Classes • What is a Design Class? • Integrates the problem domain & solution domain • problem domain → refined analysis classes • solution domain → implementation specific classes • are complete, ready to be implemented

  42. Design Classes • Concerns • responsibility • the public methods imply a contract • code evolution should be considered • inheritance • major concern of design classes (why?)

  43. Inheritance • Concerns • the strongest form of coupling between classes • “fragile base class” problem • changes in the base class impact subclasses • inflexible to change • fixed at runtime

  44. Example: Ambitious John

  45. Inheritance or Interface • Inheritance • interface & implementation • concerns with reuse • Interface • interface only • concerns with functionality contract • “design by contract” • concerns with reuse (what?)

  46. Further Considerations • Student Self-Study • Templates • Nested classes • Multiple Inheritance

  47. What is an Association? • connection between two things (usually classes) • “for a link between two object, there must be an association between the class of those objects” • link is an instance of an association • link can be represented by dependency relationship

  48. Example

  49. Reflexive Association

  50. Reflexive Association

More Related