1 / 31

Chapter 3 , Class Diagram

Chapter 3 , Class Diagram. Outline of this Class. Activity diagrams Describe the dynamic behavior of a system, in particular the workflow. Class diagrams Describe the static structure of the system: Objects, attributes, associations Use case diagrams

abiba
Download Presentation

Chapter 3 , Class Diagram

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. Chapter 3,Class Diagram

  2. Outline of this Class • Activity diagrams • Describe the dynamic behavior of a system, in particular the workflow. • Class diagrams • Describe the static structure of the system: Objects, attributes, associations • Use case diagrams • Describe the functional behavior of the system as seen by the user • Sequence diagrams • Describe the dynamic behavior between objects of the system • Statechart diagrams • Describe the dynamic behavior of an individual object

  3. zone:Zone Price: Price TarifSchedule Trip Table zone2price Enumeration getZones() Price getPrice(Zone) * * Class Diagrams • Class diagrams represent the structure of the system • Used • during requirements analysis to model application domain concepts • during system design to model subsystems • during object design to specify the detailed behavior and attributes of classes.

  4. Name TarifSchedule TarifSchedule TarifSchedule Attributes Table zone2price Enumeration getZones() Price getPrice(Zone) zone2price getZones() getPrice() Operations Classes Type Signature • A class represents a concept. • A class encapsulates state (attributes) and behavior (operations): Each attribute has a type Each operation has a signature The class name is the only mandatory information

  5. zone2price = { {‘1’, 0.20},{‘2’, 0.40}, {‘3’, 0.60}} zone2price = { {‘1’, 0.20},{‘2’, 0.40}, {‘3’, 0.60}} tarif2006:TarifSchedule :TarifSchedule Instances • An instance represents a phenomenon. • The attributes are represented with their values. • The name of an instance is underlined. • The name can contain only the class name (TarifSchedule) of the instance (anonymous instance).

  6. Actor vs Class vs Object • Actor • An entity outside the system to be modeled, interacting with the system (“Passenger”) • Class • An abstraction modeling an entity in the application or solution domain • The class is part of the system model (“User”, “Ticket distributor”, “Server”) • Object • A specific instance of a class (“Joe, the passenger who is purchasing a ticket from the ticket distributor”).

  7. Enumeration getZones() Price getPrice(Zone) TarifSchedule TripLeg PriceZone * * Associations Associations denote relationships between classes. The multiplicity of an association end denotes how many objects the instance of a class can legitimately reference.

  8. City Country 1 1 name:String name:String Point Polygon * x: Integer y: Integer draw() 1-to-1 and 1-to-many Associations 1-to-1 association 1-to-many association

  9. Many-to-Many Associations Company * * StockExchange tickerSymbol

  10. Exhaust system TicketMachine ZoneButton 0..2 1 Muffler Tailpipe diameter diameter 3 Aggregation A solid diamond denotes composition(“contains-a”): A strong form of aggregation where the life time of the component instances is controlled by the aggregate. That is, the parts don’t exist on their won (“the whole controls/destroys the parts”). • An aggregation is a special case of association denoting a “consists-of / part-of / has-a” hierarchy. • The aggregate is the parent class, the components are the children classes.

  11. Difference of Aggregation and Composition • BirörnekArabadır. ArabaParçalarındanoluşur. Bu parçalarasahiptir. EğerbirParçayoksaarababozuktur. ArabaParçalarıylaCompositionoluşturur. • AyrıcaArabanınYolcularıvardır. YolcularArabanınParçasıdeğildir. EğerbirYolcuyoksaArababozukdeğildir. ArabaYolcularınasahipdeğildir. Arabadadeğillersebaşkabiryerdedirler. İlişkigeçicidir. Yolculargelirvegider. ArabaveYolculararasındaAggregationilişkisivardır. • Her ikiilişkiaslındaComposition’dır. Arabanın hem Parçaları hem de Yolcularıvardır. Farklılıksüresindedir. Parçalarlaolanilişkidaimidir, Yolcularlaolanilişkigeçicidir.

  12. Without qualification File Directory 1 * filename 1 Directory File filename Qualifiers With qualification 0..1 • Qualification: A technique for reducing the multiplicity of associations by replacing many-to-many or one-to-many associations qith qualified associations. • Qualified association: An association in which one end is indexed by an attribute. • Qualifiers can be used to reduce the multiplicity of an association.

  13. * Lists * Company StockExchange Qualification: Another Example Company * * Lists StockExchange tickerSymbol 1 tickerSymbol

  14. CancelButton ZoneButton Button Inheritance • Inheritanceis another special case of an association denoting a “kind-of” hierarchy. • Inheritance simplifies the analysis model by introducing a taxonomy. • The children classes inherit the attributes and operations of the parent class.

  15. Account Bank Customer Packages • Packages help you to organize UML models to increase their readability. • Pretty much all UML elements can be grouped into packages. Thus, classes, objects, use cases, components, nodes, node instances etc. Can all be organized as packages. • We can use the UML package mechanism to organize classes into subsystems • Any complex system can be decomposed into subsystems, where each subsystem is modeled as a package.

  16. Foo Amount CustomerId Deposit() Withdraw() GetBalance() Object Modeling in Practice Class Identification: Name of Class, Attributes and Methods Is Foo the right name?

  17. Account Foo “Dada” Amount Amount Amount CustomerId CustomerId CustomerId Deposit() Deposit() Deposit() Withdraw() Withdraw() Withdraw() GetBalance() GetBalance() GetBalance() Object Modeling in Practice: Brainstorming Is Foo the right name?

  18. Account Amount Customer Bank Name Name AccountId Deposit() Withdraw() GetBalance() Object Modeling in Practice: More classes CustomerId CustomerId 1) Find New Classes 2) Review Names, Attributes and Methods

  19. Account Amount Bank Customer CustomerId Name Name AccountId Deposit() AccountId CustomerId Withdraw() GetBalance() Object Modeling in Practice: Associations * ? * owns has 2 1) Find New Classes 2) Review Names, Attributes and Methods 3) Find Associations between Classes 4) Label the generic assocations 5) Determine the multiplicity of the assocations 6) Review associations

  20. Account * * Has Amount Customer Bank CustomerId AccountId Name Name Deposit() AccountId CustomerId() Withdraw() GetBalance() Savings Account Checking Account Mortgage Account Withdraw() Withdraw() Withdraw() Practice Object Modeling: Find Taxonomies

  21. Account Amount CustomerId AccountId Deposit() AccountId Withdraw() GetBalance() Practice Object Modeling: Simplify, Organize Show Taxonomies separately Savings Account Checking Account Mortgage Account Withdraw() Withdraw() Withdraw()

  22. Account * * Has Amount Customer Bank AccountId CustomerId Name Name Deposit() CustomerId() Withdraw() GetBalance() Practice Object Modeling: Simplify, Organize Use the 7+-2 heuristics or better 5+-2!

  23. Practical Tips - 1 • Simplicity • To be easier to understand/takes less effort • Try to use minimal number of classes • Diagram layout • Draw diagrams in symmetric manner • Try to avoid crossing lines • Names • Descriptive, crisp, unambiguous • Singular nouns for the name of classes • References • Do not bury object references inside objects • Model these as association

  24. Practical Tips - 2 • Generalization • Do not nest subclasses too deeply • Two or three levels deep is good • Association end names • To unify references to the same class • Be alert for multiple uses of the same class • Qualified associations • To improve the precision of an association • Challenge with a multiplicity of “many” • Review • Try to get others to review model • Clarify names, improve abstraction, add info • Documentation • Diagram cannot describe the rationale • Always document models

  25. Review of Class Diagrams Multiplicity Inheritance Association End Name (Role) Class Aggregation Class diagrams represent the structure of the system

  26. Class Diagram Examples - 1

  27. Class Diagram Examples - 2

  28. Class Diagram Examples - 3

  29. Class Diagram Examples - 4

  30. Class Diagram Examples - 5

  31. Another view on UML Diagrams

More Related