1 / 35

Chapter 2, Modeling with UML

Chapter 2, Modeling with UML. Use Case Diagrams: Summary. Use case diagrams represent external behavior Use case diagrams are useful as an index into the use cases Use case descriptions provide meat of model, not the use case diagrams.

ashlyn
Télécharger la présentation

Chapter 2, Modeling with UML

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 2,Modeling with UML

  2. Use Case Diagrams: Summary • Use case diagrams represent external behavior • Use case diagrams are useful as an index into the use cases • Use case descriptions provide meat of model, not the use case diagrams. • All use cases need to be described for the model to be useful.

  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 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. 1 Country City 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 * * tickerSymbol StockExchange

  10. Class Diagram: Company * * StockExchange Lists tickerSymbol From Problem Statement To Object Model Problem Statement: A stock exchange lists many companies. Each company is uniquely identified by a ticker symbol

  11. Java Code public class StockExchange { }; public class Company { }; From Problem Statement to Code Pr oblem Statement : A stock exchange lists many companies. Each company is identified by a ticker symbol Class Diagram: * * Company StockExchange Lists tickerSymbol private Vector m_Company = new Vector(); Associations are mapped to Attributes! public int m_tickerSymbol; private Vector m_StockExchange = new Vector();

  12. Exhaust system TicketMachine ZoneButton 0..2 1 Muffler Tailpipe diameter diameter 3 Aggregation A solid diamond denotes composition: 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 own (“the whole controls/destroys the parts”) • An aggregation is a special case of association denoting a “part-of” hierarchy • The aggregate is the parent class, the components are the children classes

  13. Without qualification File Directory 1 * filename 1 Directory filename File Qualifiers With qualification 1 • Qualifiers identify subsets of related instances in association navigations; they provide a model of indices or keys for association ends. • Qualifiers can be used to reduce the multiplicity of an association

  14. * Lists * Person Bank Qualification: Another Example Person * * Lists accountNumber Bank 0..1 accountNumber

  15. CancelButton ZoneButton Button Inheritance • Inheritance is 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.

  16. Account Bank Customer Packages • Packages help you to organize UML models to increase their readability • 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.

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

  18. 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?

  19. 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

  20. 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

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

  22. 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()

  23. Account * * Has Amount Customer Bank CustomerId Name Name AccountId Deposit() AccountId CustomerId() Withdraw() GetBalance() Practice Object Modeling: Simplify, Organize

  24. Used during analysis To refine use case descriptions to find additional objects (“participating objects”) Used during system design to refine subsystem interfaces Instances are represented by rectangles. Actors by sticky figures Lifelines are represented by dashed lines Messages are represented by arrows Activations are represented by narrow rectangles. TicketMachine Passenger selectZone() insertCoins() TicketMachine pickupChange() zone2price selectZone() insertCoins() pickupChange() pickUpTicket() pickUpTicket() Focus on control flow Sequence Diagrams Messages -> Operations on participating Object

  25. ZoneButton TarifSchedule Display Passenger selectZone() lookupPrice(selection) price displayPrice(price) Sequence Diagrams can also model the Flow of Data Dataflow • The source of an arrow indicates the activation which sent the message • Horizontal dashed arrows indicate data flow, for example return results from a message …continued on next slide...

  26. CoinIdentifier Display CoinDrop Passenger insertChange(coin) lookupCoin(coin) value displayPrice(owedAmount) [owedAmount<0] returnChange(-owedAmount) Sequence Diagrams: Iteration & Condition …continued from previous slide... ChangeProcessor * Iteration Condition • Iteration is denoted by a * preceding the message name • Condition is denoted by boolean expression in [ ] before the message name …continued on next slide...

  27. Passenger createTicket(selection) Ticket print() free() Creation and destruction …continued from previous slide... Creation of Ticket ChangeProcessor Destruction of Ticket • Creation is denoted by a message arrow pointing to the object • Destruction is denoted by an X mark at the end of the destruction activation • In garbage collection environments, destruction can be used to denote the end of the useful life of an object.

  28. Sequence Diagram Properties • UML sequence diagram represent behavior in terms of interactions • Useful to identify or find missing objects • Time consuming to build, but worth the investment • Complement the class diagrams (which represent structure).

  29. Activity Diagrams • An activity diagram is a special case of a state chart diagram • The states are activities (“functions”) • An activity diagram is useful to depict the workflow in a system

  30. Activity Diagrams allow to model Decisions Decision

  31. Activity Diagrams can model Concurrency • Synchronization of multiple activities • Splitting the flow of control into multiple threads Splitting Synchronization

  32. Activity Diagrams: Grouping of Activities • Activities may be grouped into swimlanes to denote the object or subsystem that implements the activities. Dispatcher Allocate Resources Open Coordinate Archive Incident Resources Incident FieldOfficer Document Incident

  33. Activity Diagram vs. Statechart Diagram Statechart Diagram for Incident Focus on the set of attributes of a single abstraction (object, system) Event causes state transition Closed Active Inactive Archived Incident- Documented Incident- Archived Incident- Handled Activity Diagram for Incident (Focus on dataflow in a system) Triggerless transition Completion of activity causes state transition

  34. UML Summary • UML provides a wide variety of notations for representing many aspects of software development • Powerful, but complex • UML is a programming language • Can be misused to generate unreadable models • Can be misunderstood when using too many exotic features • We concentrated on a few notations: • Functional model: Use case diagram • Object model: class diagram • Dynamic model: sequence diagrams, statechart and activity diagrams

  35. Additional References • Martin Fowler • UML Distilled: A Brief Guide to the Standard Object Modeling Language, 3rd ed., Addison-Wesley, 2003 • Grady Booch,James Rumbaugh,Ivar Jacobson • The Unified Modeling Language User Guide, Addison Wesley, 2nd edition, 2005 • Commercial UML tools • Rational Rose XDE for Java • http://www-306.ibm.com/software/awdtools/developer/java/ • Together (Eclipse, MS Visual Studio, JBuilder) • http://www.borland.com/us/products/together/index.html • Open Source UML tools • http://java-source.net/open-source/uml-modeling • ArgoUML,UMLet,Violet, …

More Related