Chapter 2, Modeling with UML, Part 2

Slides:



Advertisements
Similar presentations
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Advertisements

Chapter 4,Use Case and Statechart Diagrams
Software analysis and design tools T120B pavasario sem.
Slides by Bruegee and Dutoit, Modified by David A. Gaitros COP 3331 Object Oriented Analysis and Design Chapter 2: Object Oriented Modeling using UML Jean.
Chapter 2, Modeling with UML, Part 2
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Chapter 3,Class Diagram.
Interaction Diagrams Software Engineering BIT8. Interaction Diagrams  A series of diagrams describing the dynamic behavior of an object-oriented system.
Chapter 2, Modeling with UML
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 UML First Pass: Class Diagrams Battery load()
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
© Copyright Eliyahu Brutman Programming Techniques Course.
Using UML, Patterns, and Java Object-Oriented Software Engineering Modeling with UML Chapter 2 Object-Oriented Software Engineering: Using UML, Patterns,
1 Modeling with UML CMPE 131 Fall Overview What is modeling? What is UML? Use case diagrams Class diagrams Sequence diagrams Activity diagrams.
Unified Modeling Language
SEQUENCE DIAGRAM Prepared by: T. Fatimah Alageel.
Introduction to UML CS A401. What is UML? Unified Modeling Language –OMG Standard, Object Management Group –Based on work from Booch, Rumbaugh, Jacobson.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML.
COP 3331 Object-Oriented Analysis and Design 1 Modeling and UML  UML = Unified Modeling Language  Graphical Notation  Topics  Modeling  Basics of.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Introduction to Software Engineering ECSE-321 Unit 5 – Modeling with UML.
Modeling with UML Chapter 2 Object-Oriented Software Engineering: Using UML, Patterns, and Java, 2 nd Edition By B. Bruegge and A. Dutoit Prentice Hall,
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Chapter 2, Modeling with UML, Part 2
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML: Review Session (Optional)
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML: Review Session (Optional)
UML Review of diagram types. 2 Unified Modeling Language The Unified Modeling Language™ (UML) was developed jointly by Grady Booch, Ivar Jacobson, and.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
An Introduction to the Unified Modeling Language
1 An Introduction to UML Interaction (Sequence and Communication) Diagrams Georgia State University CIS 3300 Spring, 2009.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 Software Engineering September 19, 2001 UML.
UML as a Specification Language for Embedded Systems. By, Mir Ahmed Ali, Asst. Professor, ECM department, SNIST. By, Prof. Narsiah sir, Director of School.
Introduction to UML 임현승 강원대학교 Revised from the slides by Bernd Bruegge and Allen H. Dutoit for the book “Object-Oriented Software Engineering: Using UML,
Using UML, Patterns, and Java Object-Oriented Software Engineering More on UML Note: Slides are adapted by Linda Sherrell from the Software Engineering.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
UML Review of Use case diagrams. 2 Unified Modeling Language The Unified Modeling Language™ (UML) was developed jointly by Grady Booch, Ivar Jacobson,
Chapter 3: Introducing the UML
UML Review Overview: modeling with UML  What is modeling?  What is UML?  Use case diagrams  Class diagrams  Sequence diagrams  Activity diagrams.
CEN 5011 Advanced Software Engineering
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 2, Modeling with UML.
Object Oriented Analysis System modeling = Functional modeling + Object modeling + Dynamic modeling Functional modeling = Use cases Object modeling =class.
1 After the scenarios are formulated Find all the use cases in the scenario Describe each of these use cases in more detail Participating actors Describe.
1 Object Oriented Analysis System modeling = Functional modeling + Object modeling + Dynamic modeling Functional modeling = Use cases Object modeling =class.
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 14 Slide 1 Object-Oriented Design.
Systems Analysis and Design in a Changing World, Fourth Edition
Chapter 2, Modeling with UML
UML Review.
Modeling with UML Chapter 2
Chapter 2, Modeling with UML
Chapter 2: Modeling with UML - 2
Introduction to UML.
Evolution of UML.
Introduction to UML.
Course Outcomes of Object Oriented Modeling Design (17630,C604)
Before we start Project Group A note about class project ArgoUML
Object-Oriented Analysis and Design
CS410 – Software Engineering Lecture #17: UML I
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
UML Class Diagram.
Chapter 2, Modeling with UML
Chapter 2, Modeling with UML
Copyright 2007 Oxford Consulting, Ltd
CS410 – Software Engineering Lecture #9: UML
Chapter 2, Modeling with UML
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
Presentation transcript:

Chapter 2, Modeling with UML, Part 2

What is UML? Unified Modeling Language Convergence of different notations used in object-oriented methods, mainly OMT (James Rumbaugh and collegues), OOSE (Ivar Jacobson), Booch (Grady Booch) They also developed the Rational Unified Process, which became the Unified Process in 1999 At Ericsson until 1994, developed use cases and the CASE tool Objectory, at IBM Rational since 1995, http://www.ivarjacobson.com 25 year at GE Research, where he developed OMT, joined (IBM) Rational in 1994, CASE tool OMTool Developed the Booch method (“clouds”), ACM Fellow 1995, and IBM Fellow 2003 http://www.booch.com/

UML Nonproprietary standard for modeling systems Current Version: UML 2.5 Information at the OMG portal http://www.uml.org/ Commercial tools: Rational (IBM),Together (Borland), Visual Architect (Visual Paradigm), Enterprise Architect (Sparx Systems) Open Source tools http://www.sourceforge.net/ ArgoUML, StarUML, Umbrello (for KDE), PoseidonUML Example of research tools: Unicase, Sysiphus Based on a unified project model for modeling, collaboration and project organization http://unicase.org http://sysiphus.in.tum.de/

UML: First Pass You can solve 80% of the modeling problems by using 20% UML We teach you those 20% 80-20 rule: Pareto principle Vilfredo Pareto, 1848-1923 Introduced the concept of Pareto Efficiency, Founder of the field of microeconomics.

UML First Pass Use case diagrams Class diagrams Sequence diagrams Describe the functional behavior of the system as seen by the user Class diagrams Describe the static structure of the system: Objects, attributes, associations Sequence diagrams Describe the dynamic behavior between objects of the system Statechart diagrams Describe the dynamic behavior of an individual object Activity diagrams Describe the dynamic behavior of a system, in particular the workflow. Statechart diagrams Describe the dynamic behavior of an individual object (essentially a finite state automaton) Activity Diagrams Model the dynamic behavior of a system, in particular the workflow (essentially a flowchart)

UML Basic Notation: First Summary UML provides a wide variety of notations for modeling many aspects of software systems We have already looked at: Functional model: Use case diagram Object model: Class diagram Dynamic model: Sequence diagrams, statechart Now we go into a little bit more detail… Powerful, but complex language Can be misused to generate unreadable models Can be misunderstood when using too many exotic features

UML Use Case Diagrams Used during requirements elicitation and analysis to represent external behavior (“visible from the outside of the system”) Passenger An Actor represents a role, that is, a type of user of the system A use case represents a class of functionality provided by the system PurchaseTicket Use case model: The set of all use cases that completely describe the functionality of the system.

Actors An actor is a model for an external entity which interacts (communicates) with the system. Examples of actors include: User roles (e.g. system administrator, bank customer) External system (Another system), e.g., a central database. Physical environment (e.g. Weather) An actor has a unique name and an optional description Examples: Passenger: A person in the train GPS satellite: An external system that provides the system with GPS coordinates. Passenger Optional Description Name

Use Case A use case describes a function provided by the system as a set of events that yields a visible result for the actors. • Use cases can be described textually, with a focus on the event flow between actor and system • The textual use case description consists of 6 parts: Unique name Participating actors Entry conditions Exit conditions Flow of events Special requirements. PurchaseTicket

Textual Use Case Description Example Passenger Textual Use Case Description Example PurchaseTicket 1. Name: Purchase ticket 2. Participating actor: Passenger 3. Entry condition: Passenger stands in front of ticket distributor Passenger has sufficient money to purchase ticket 4. Exit condition: Passenger has ticket 5. Flow of events: 1. Passenger selects the number of zones to be traveled 2. Ticket Distributor displays the amount due 3. Passenger inserts money, at least the amount due 4. Ticket Distributor returns change 5. Ticket Distributor issues ticket 6. Special requirements: None. Question: Anything missing? Answer: Exceptional cases! Use cases represent functionality of the system All use cases need to be described for the model to be useful Use case diagrams are useful as an index into the use cases The Textual Use case descriptions provide meat of model, not the use case diagrams.

Another well-formed description!

Use case Diagram Relationships Use case diagrams can include four types of relationships: Communication inclusion extension inheritance

Communication relationships Actors and use cases communicate when information is exchanged between them. Communication relationships are depicted by a solid line between the actor and use case symbol. Field Officer and Dispatcher communicate with the Report Emergency use case.

Uses Cases can be related Extends Relationship To represent seldom invoked use cases or exceptional functionality Includes Relationship To represent functional behavior common to more than one use case.

The <<include>> Relationship When describing a complex system, its use case model can become quite complex and can contain redundancy. We reduce the complexity of the model by identifying commonalities in different use cases. Two use cases are related by an include relationship if one of them includes the second one in its flow of events. include relationships are depicted by a dashed open arrow originating from the including use case.

Example ViewMap is included by the use cases Open Incident and Allocate Resources

The <<include>> Relationship (Cont.) Passenger <<include>> relationship represents common functionality needed in more than one use case <<include>> behavior is factored out for reuse, not because it is an exception The direction of a <<include>> relationship is to the using use case (unlike the direction of the <<extends>> relationship. PurchaseMultiCard PurchaseSingleTicket <<include>> <<include>> CollectMoney NoChange <<extend>> Cancel

The <<extend>> Relationship Extend relationships are an alternate means for reducing complexity in the use case model. A use case can extend another use case by adding events. An extend relationship indicates that an instance of an extended use case may include (under certain conditions) the behavior specified by the extending use case. Extend relationships are depicted by a dashed open arrow originating from the extending use case to the extended one.

The <<extend>> Relationship--Example Assume that the network connection between the Dispatcher and the FieldOfficer can be interrupted at any time. The use case ConnectionDown describes the set of events taken by the system and the actors while the connection is lost. ConnectionDown extends the use cases OpenIncident and AllocateResources

The <<extend>> Relationship (Cont.) <<extend>> relationships model exceptional or seldom invoked cases The exceptional event flows are factored out of the main event flow for clarity The direction of an <<extend>> relationship is to the extended use case Use cases representing exceptional flows can extend more than one use case. Passenger PurchaseTicket <<extend>> <<extend>> <<extend>> <<extend>> OutOfOrder TimeOut Cancel NoChange

Inheritance Relationship quick search Advanced search search by theme Surfer Search for books

Class Diagrams Class diagrams represent the structure of the system Used during: requirements analysis to model application domain concepts system design to model subsystems object design to specify the detailed behavior and attributes of classes

1. Classes Type Name Attributes Operations Signature Zone2price:Table getZones():Enumeration getPrice(zone:Zone):Price TarifSchedule zone2price getZones() getPrice() TarifSchedule Name Attributes Operations Signature TarifSchedule A class represents a concept A class encapsulates state (attributes) and behavior (operations) By convention, class names start with an uppercase letter Each attribute has a type Each operation has a signature The class name is the only mandatory information

Instances An instance represents a phenomenon zone2price = { {‘1’, 0.20}, {‘2’, 0.40}, {‘3’, 0.60}} tarif2006:TarifSchedule zone2price = { {‘1’, 0.20}, {‘2’, 0.40}, {‘3’, 0.60}} :TarifSchedule 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)

Classes and Objects—another example

Actor vs Class vs Object 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”). What is the difference between an actor, a class and an instance?

2. Associations and links Associations are relationships between classes A link represents a connection between two objects. For example, each FieldOfficer object also has a list of EmergencyReports that has been written by the FieldOfficer.

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

Multiplicity Each end of an association can be labeled by a set of integers indicating the number of links that can legitimately originate from an instance of the class connected to the association end. This set of integers is called the multiplicity of the association end The “many” multiplicity is shorthand for 0..n and is shown as a star. An association end can have an arbitrary set of integers as a multiplicity. In practice, most of the associations we encounter belong to one of the following three types.

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

Multiplicity: Many-to-Many Associations Company * * StockExchange tickerSymbol A stock exchange lists many companies each of them uniquely identifed by a ticker symbol used at that stock exchange. A company can be listed on more than one stock exchange, using the same ticker symbol. Mercedes Benz is an example for a company listed on more than one stock exchange: Frankfurt and NYSE. Does it have two different Ticker symbols? Something not clear here: What happens if the company cannot have the same ticker symbol on two different stock exchanges?

Multiplicity—Another Example

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

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

Aggregation An aggregation is a special case of association denoting a “consists-of” hierarchy The aggregate is the parent class, the components are the children classes Exhaust system Muffler diameter Tailpipe 1 0..2 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 won (“the whole controls/destroys the parts”) Example for composition: Bill of Material TicketMachine ZoneButton 3

Aggregation—Another Example

Qualifiers Qualification is a technique for reducing multiplicity by using keys. Qualification is a technique for reducing multiplicity by using keys. Associations with a 0..1 or 1 multiplicity are easier to understand than associations with a 0..n or 1..n multiplicity. Often in the case of a one-to-many association, objects on the “many” side can be distinguished State County Township PoliceStation PoliceOfficer Directory File A Deeper View into UML 57 from one another using a name. For example, in a hierarchical file system, each file belongs to exactly one directory. Each file is uniquely identified by a name in the context of a directory. Many files can have the same name in the context of the file system; however, two files cannot share the same name within the same directory. Without qualification (see top of Figure 2-31), the association between Directory and File has a one multiplicity on the Directory side and a zero-to-many multiplicity on the File side. We reduce the multiplicity on the File side by using the filename attribute as a key, also called a qualifier (see top of Figure 2-31). The relationship between Directory and File is called a qualified association. The relationship between Directory and File is called a qualified association.

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

Inheritance Button ZoneButton CancelButton 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. Later we will also see how inheritance allows the reuse of solutions (implementation and specification inheritance)

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 Account Bank Customer Packages are the grouping construct with

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

Object Modeling in Practice: Brainstorming “Dada” Amount CustomerId Deposit() Withdraw() GetBalance() Foo Amount CustomerId Deposit() Withdraw() GetBalance() Account Amount CustomerId Deposit() Withdraw() GetBalance() Naming is important! Is Foo the right name?

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

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

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

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

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

Sequence Diagrams Focus on Controlflow Used during analysis Passenger 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 selectZone() pickupChange() pickUpTicket() insertCoins() zone2price selectZone() insertCoins() pickupChange() pickUpTicket() TicketMachine Messages -> Operations on participating Object

Sequence Diagrams can also model the Flow of Data Passenger selectZone() ZoneButton TarifSchedule Display lookupPrice(selection) displayPrice(price) price Dataflow …continued on next slide... 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

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

Creation and destruction Passenger …continued from previous slide... Creation of Ticket ChangeProcessor Ticket createTicket(selection) print() Destruction of Ticket free() 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.

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

UML Diagrams A more detailed view on Use case diagrams Class diagrams Sequence diagrams Activity diagrams We provided already a basic overview of the notations: Use case diagrams Class diagrams Sequence diagrams, statechart diagrams We will now go int more detail and cover two additional notations as well, sequence diagrams and activity diagrams

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 There are two types of states: Action state: Cannot be decomposed any further Happens “instantaneously” with respect to the level of abstraction used in the model Activity state: Can be decomposed further The activity is modeled by another activity diagram

Activity Diagrams allow to model Decisions

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

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

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 Active Inactive Closed Archived Incident- Documented Incident- Handled Incident- Archived Activity Diagram for Incident (Focus on dataflow in a system) Statechart Diagram for Incident (similar to Mealy Automaton) Activity Diagram for Incident (similar to Moore Automaton) Triggerless transition Completion of activity causes state transition

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