View
20
Download
0
Category
Tags:
Preview:
Citation preview
ObjectObject--Oriented Software EngineeringOriented Software Engineering
Chapter 2
Unified ModelingLanguage
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Introduction• A model is an abstract representation
of a system, constructed to understand the system prior to building or modifying it.
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
building or modifying it. • Most of the modeling techniques
involve graphical languages.
Why Modeling?• Models make it easier to express complex
ideas. For example, an architectbuilds a model to communicate ideasmore easily to clients.
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
• Models reduce complexity by separatingthose aspects that are unimportant fromthose that are important.
Advantages of Modeling (Con’t)• Models enhance learning.• The cost of the modeling analysis is
much lower than the cost of similar experimentation conducted with a
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
experimentation conducted with a real system.
• Manipulation of the model (changing variables) is much easier than manipulating a real system.
Modeling Key Ideas
• A model is rarely correct on the first try.
• Always seek the advice and
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
• Always seek the advice and criticism of others.
• Avoid excess model revisions, as they can distort the essence of your model. Let simplicity and elegance guide you through the process.
The Unified Modeling Language (UML)
• The unified modeling language (UML) is alanguage for specifying, constructing,visualizing, and documenting the softwaresystem and its components.
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
A complete language for capturingknowledge (semantics) about asubject (system) andcommunicating the knowledge(syntax)
Primary goals in the design of the UML• Provide users a ready-to-use, expressive visual
modeling language to develop and exchangemeaningful models.
• Provide extensibility and specializationmechanisms to extend the core concepts.mechanisms to extend the core concepts.
• Be independent of particular programminglanguages and development processes.
• Provide a formal basis for understanding themodeling language.
• Encourage the growth of the OO tools market.• Support higher-level development concepts
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
History and Background
8
History of the UMLHistory of the UML
Nov ‘97 UML approved by the OMG
Creating UML
Static Views are modeled using Use Case Diagrams Class Diagrams Object Diagrams Component Diagrams Deployment Diagrams
What can you model with UML?
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Deployment Diagrams
Dynamic Views are modeled usingSequence DiagramsCollaboration DiagramsActivity DiagramsState-chart Diagrams
Static Model• A static model can be viewed as a
"snapshot" of a system's parameters at rest or at a specific point in time.
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
point in time. • The classes’ structure
and their relationshipsto each other frozen in time are examples of static models.
Dynamic Model
• Is a collection of procedures orbehaviors that, taken together,reflect the behavior of a systemover time.
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
over time.• For example, an order interacts
with inventory to determineproduct availability.
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Building Blocks of UMLTo understand the UML, you need to form a
conceptual model of the language, and thisrequires learning three basic building blocks:
1. Elements: Main “citizens” of the model2. Relationships: tie elements together3. Diagrams: mechanisms to group
interesting collections of elements andrelationships
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Elements in UML
Structural Elements
1.Classes
Behavioral Elements
1. Interactions
Grouping Elements
Annotation Elements
1.Classes
2. Interfaces
3. Collaborations
4. Use cases
5. Active classes
6. Components
7. Node classes
1. Interactions
2. State Charts 1. Package 1. Note
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Structural Elements
1.1. ClassClass:: It is a description of a set of objects
that share the same attributes,
Static part of the model to represent conceptual or physicalelements
“nouns” of the model
that share the same attributes,operations, relationships, andsemantics.
implements one or more interfaces. Graphically, a class is rendered as a
rectangle, usually including its name,attributes, and operations
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Structural Elements
22.. InterfaceInterface::• is a collection of operations that
specify a service of a class orcomponent.
• An interface might represent thecomplete behavior of a class orcomponent or only a part of thatbehavior
• An interface rarely stands alone.
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Agency
Structural Elements33.. ColloborationColloboration::• Defines an interaction between
elements• Several elements cooperating to
deliver a behavior rather thanindividual behavior
Capture online
individual behavior• Includes structural and behavioral
dimensions• Represents implementations of
patterns that make up a system
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Structural Elements44.. UseUse CasesCases::• Description of a sequence of
actions that a system performs todeliver an observable result to aparticular actor
• Used to structure the behavioral• Used to structure the behavioralelements in a model
• Realized by collaboration• Graphically rendered as an
ellipse drawn with a solid line
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Structural Elements55.. ActiveActive ClassesClasses::• A class whose objects own one or
more processes or threads andtherefore can initiate an action
• A class whose objects haveconcurrent behavior with otherconcurrent behavior with otherobjects
• Graphically, an active class isrendered just like a class drawnwith a thick line
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Structural Elements6.6. ComponentComponent
• is a physical and replaceable part of a system that conforms to and provides the realization of a set of interfaces. interfaces.
• Graphically, a component is rendered as a rectangle with tabs
• it also can be used to represent applications, files, libraries,pagesand tables.
•
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Structural Elements77.. NodeNode ClassClass::• is a physical element that exists at run
time • represents a computational resource,
generally having at least some memory and, often, processing capability. and, often, processing capability.
• a set of components may reside in a node• components may also migrate from one
node to another• Graphically, a node is rendered as a cube,
usually including only its name
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Behavioral Elements
11.. InteractionInteraction::• a set of messages exchanged among a set of objects
within a particular context to accomplish a specific
These are the dynamic parts of UML models. Represent behavior over time and space“verbs” of the model
Save application()
within a particular context to accomplish a specific purpose
• specifies the behavior of a set of objects• involves a number of other elements:
– messages, action sequences (behavior invoked by a message) and links (connection between objects)
• graphically rendered as an arrow
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Behavioral Elements22.. StateState MachineMachine::• specifies a sequence of states an object or an
interaction goes through during its lifetime and its response to external events
• may specify the behavior of an individual class or a collaboration of classescollaboration of classes
• includes a number of elements including states, transition, events and activities
• presented as a rounded rectangle with a name and sub-• states
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Grouping Element
1.1. PackagePackage::• mechanism for organizing elements
into groups.
Are the organizational parts of UML models. These are the boxesinto which a model can be decomposed .There is one primarykind of grouping thing, namely, packages.
into groups.• All elements can be placed in a package.• Graphically, a package is rendered as a
tabbed folder, usually including only itsname and, sometimes, its contents
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Annotational Element
1.1. NoteNote::• comments added to models for better
explanation or illumination on specific elements
are the explanatory parts of UML models. These are thecomments you may apply to describe about any element in amodel.
explanation or illumination on specific elements• explanatory aspect of UML models• notes are used primarily for annotation e.g. for
rendering constraints and comments attached to elements or collections of elements
• presented as a rectangle with a dog-eared corner• may include both textual and graphical comments
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Relationships in the UML
1.1. DependencyDependency::
There are four kinds of relationships in the UML: 1. Dependency 2. Association 3. Generalization 4. Realization
1.1. DependencyDependency::• A semantic relationship between two
elements in which a change to oneelement (independent element) mayaffect the meaning of the other(dependent element)
• Given as a directed dashed line possiblywith a label
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Relationships in the UML22.. AssociationAssociation::• a structural relationship describing a set of links• links are connections between objects• aggregation is a special type of association depicting
whole-part relationshipwhole-part relationship• association is presented as a solid line, possibly
directed, labeled and with adornments (multiplicityand role)
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Relationships in the UML33.. GeneralizationGeneralization• a relationship in which objects of a
specialized element (child) are substitutable for objects of a generalized element (parent)
• child elements share the structure • child elements share the structure and behavior of the parent
• rendered graphically as a solid line with hollow arrow head pointing to the parent
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Relationships in the UML44.. RealizationRealization::• a semantic relationship between
elements, wherein one element specifiesa contract and another guarantees tocarry out this contract
• relevant in two basic scenarios:• relevant in two basic scenarios:– interfaces versus realizing classes or
components– uses cases versus realizing collaborations
• graphically depicted as a dashed arrowwith hollow head a cross betweendependency and generalization
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML
• a graph presentation of a set of elements and relationships where:– nodes are elements– edges are relationships
• UML includes nine such diagrams
1. Class Diagram
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML1. Class Diagram: o Static structure of a
system
o Show a set of classes, interfaces, collaboration,
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
interfaces, collaboration, and their relationships
o address static design view of a system
Diagrams in UML2. Object Diagram: Static structure of a system at a particular time Show a set of objects and their relationshipsstatic snapshots of element instances found in class diagrams
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML3. Use Case Diagram: Functionality of a system Show a set of actors and use cases, and their relationshipsaddresses static use case view of the systemimportant for organizing and modeling the external behavior of the system
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
behavior of the system
Diagrams in UML4. Sequence Diagram: Interaction among elements of a system in a time sequence show interactions consisting of a set of objects and the messages sent and received by
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
objects and the messages sent and received by those objects address the dynamic behavior of a system with special emphasis on the chronological ordering of messages
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML5.Collaboration Diagram:
Interaction among elements and their relationsorganized in time and space
Show the structural organization of objects
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Show the structural organization of objects that send and receive messages
Sequence and collaboration diagram are isomorphic i.e. one can be transformed into another
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML6. State Chart Diagram:
The status condition and responses of the elements ofa system
Show a state machine consisting of states, transitions,events, and activities
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
events, and activities address the dynamic view of a system important in modeling the behavior of an interface,
class or collaboration emphasize on event-driven ordering
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML7. Activity Diagram:
The activities of the system a diagram showing control/data flows from one
activity to another addresses the dynamic view of a system, useful for
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
addresses the dynamic view of a system, useful formodeling its functions
emphasizes the flow of control among objects
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML8.Component Diagram:
The organization of the elements realizing the systemShow the organization and dependencies amongst a
set of components address static implementation view of a system
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
address static implementation view of a system a component typically maps to one or more classes,
interfaces or collaborations
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Diagrams in UML9.Deployment Diagram:
Configuration of environment elements and themapping of elements realizing the system into them
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Object-Oriented Systems Development Bahrami © Irwin/ McGraw-Hill
Recommended