UML / UML 2.0 tutorial

  • View
    95

  • Download
    8

Embed Size (px)

DESCRIPTION

Ileana Ober IRIT – UPS, Toulouse, France http://www.irit.fr/~Ileana.Ober. UML / UML 2.0 tutorial. Modeling in the ’80 – ’90s. Lots of (slightly different) languages and design techniques OMT Coad & Yourdon BON SDL ROOM Shlaer Mellor … Quite a mess. - PowerPoint PPT Presentation

Text of UML / UML 2.0 tutorial

  • UML / UML 2.0 tutorialIleana OberIRIT UPS, Toulouse, Francehttp://www.irit.fr/~Ileana.Ober

    UML tutorial Ileana Ober

    Modeling in the 80 90sLots of (slightly different) languages and design techniquesOMTCoad & YourdonBONSDLROOMShlaer Mellor Quite a mess

    UML tutorial Ileana Ober

    In use with permission from PIB Copenhagen A/S, obtained august 2005

    UML tutorial Ileana Ober

    UMLSought as a solution to the OOA&D messAims at Unifying design languagesBeing a general purpose modeling languageLingua franca of modeling

    UML tutorial Ileana Ober

    OverviewWhat is UML?Structure descriptionBehavior descriptionOCLUML and tools

    UML tutorial Ileana Ober

    UML (Unified Modeling Language)Goal: lingua franca in modelingDefinition driven by consensus rather than innovationDefinition style:Described by a meta-model (abstract syntax)Well formedness rules in OCLTextual descriptionstatic and dynamic semantics (in part already described by WFRs)notation descriptionusage notes

    UML tutorial Ileana Ober

    Overview of the 13 diagrams of UMLStructure diagramsClass diagramComposite structure diagram (*)Component diagramDeployment diagramObject diagramPackage diagramBehavior diagramsUse-case diagramState machine diagramActivity diagramInteraction diagramsSequence diagramCommunication diagram Interaction overview diagram (*)Timing diagram (*)

    (*) not existing in UML 1.x, added in UML 2.0

    UML tutorial Ileana Ober

    UML principle: diagram vs. modelDifferent diagrams describe various facets of the model

    Several diagrams of the same kind may coexist

    Each diagram shows a projection of the model

    Incoherence between diagrams (of the same or of different kind(s)) correspond to an ill-formed model

    The coherence rules between different kinds of diagrams is not fully stated

    UML tutorial Ileana Ober

    This tutorial looks closer at Use case diagramClass diagram Composite structure diagramComponent/deployment diagramState machine diagram Activity diagramInteraction diagrams

    UML tutorial Ileana Ober

    OverviewWhat is UML?Structure descriptionUse case diagramClass diagramComposite structure diagramCommunication principles in UMLSystem initializationBehavior descriptionOCLUML and tools

    UML tutorial Ileana Ober

    Use case diagramDisplays the relationship among actors and use cases, in a given system

    Main concepts:System the system under modelingActor external user of the systemUse case execution scenario, observable by an actor

    UML tutorial Ileana Ober

    Use case diagram exampleARTIST Summer School Website

    UML tutorial Ileana Ober

    Use case diagram final remarksWidely used in real-life projectsUsed at:Exposing requirementsCommunicate with clientsPlanning the projectAdditional textual notes are often used/required

    User-centric, non formal notationFew constraints in the standard

    Further reading:

    D. Rosenberg, K.Scott Use Case Driven Object Modeling with UML : A Practical Approach, Addison-Wesley Object Technology Series, 1999 I. Jacobson, Object-Oriented Software Engineering: A Use Case Driven Approach, Addison-Wesley Professional, 1999Writing Effective Use Cases Alistair Cockburn Addison-Wesley Object Technology Series, 2001

    UML tutorial Ileana Ober

    OverviewWhat is UML?Structure descriptionUse case diagramClass diagramComposite structure diagramCommunication principles in UMLSystem initializationBehavior descriptionOCLUML and tools

    UML tutorial Ileana Ober

    Class diagramThe most known and the most used UML diagramGives information on model structural elementsMain concepts involvedClass - ObjectInheritanceAssociation (various kinds of)

    UML tutorial Ileana Ober

    Lets start with object orientationWhy OO?In the first versions, UML was described as addressing the needs of modeling systems in a OO mannerStatement not any longer maintained, however the OO inspiration for some key concepts is still thereMain concepts:Object individual unit capable of receiving/sending messages, processing dataClass pattern giving an abstraction for a set of objectsInheritance technique for reusability and extendibility

    Further reading:Bertrand Meyer: Object-Oriented Software Construction, 2nd edition, Prentice Hall, 2000

    UML tutorial Ileana Ober

    UML ClassGives the type of a set of objects existing at run-timeDeclares a collection of methods and attributes that describe the structure and behavior of its objectsBasic notation:

    UML tutorial Ileana Ober

    Properties of UML classesMay own featuresStructural (data related) : attributesBehavioral : operations

    May own behavior (state machines, interactions, )

    May be instantiated except for abstract classes that can NOT be directly instantiated and exist only for the inheritance hierarchy

    UML tutorial Ileana Ober

    Class features characterized bySignatureVisibility (public, private, protected, package)Changeability (changeable, frozen, addOnly)Owner scope (class, instance) equivalent to static clause in programming languagesInvariant constraint

    Additionally, operations are characterized by concurrency kind: sequential, guarded, concurrentpre or post conditionsbody (state machine or action description)

    UML tutorial Ileana Ober

    Decode class symbol adornmentsClass name in italics: abstract classUnderlined attribute = class attribute

    Simple class box: passive classFeature visibility +, -, #,~Attributes areaOperations area

    UML tutorial Ileana Ober

    Active / passive classesspecifies the concurrency model for classesspecifies whether an Object of the Class maintains its own thread of control and runs concurrently with other active Objects (active)

    Thick box: active class

    GSMOperator

    Subscriber

    n

    *

    MobilePhone

    *

    *

    n

    1

    +network

    *

    +phone

    *

    +provider

    n

    +client

    *

    +phone

    n

    +owner

    1

    UML tutorial Ileana Ober

    ObjectInstance of a classCan be shown in a class diagramNotation

    UML tutorial Ileana Ober

    Inheritance A.k.a. generalization (specialization)Applies mainly on classesOther UML model elements can be subject to inheritance (e.g. interface) (if you want the exact list go check the UML metamodel for kinds of GeneralizableElements)Allows for polymorphism

    UML tutorial Ileana Ober

    Inheritance/polymorphism exampleAnimal a;Cow cw;Cat ct;..if ()a:= cwelsea:= ctendif

    a.cry() --- should be a mooo or a meow depending on the

    UML tutorial Ileana Ober

    AssociationConcept with no direct equivalent in common programming languagesIs defined as a semantic relationship between classes, that can materialize at runtime The instance of an association is a set of tuples relating instances of the classes

    Its actual nature may vary, in terms of code, they may correspond toAttributes, pointersOperationsGraphical comments

    UML tutorial Ileana Ober

    Examplevehicle1UsesVehicle *passengerAssociation symbolAssociation end

    UML tutorial Ileana Ober

    Example at instance levelLink symbol

    UML tutorial Ileana Ober

    Example at instance levelNote on style in UML diagrams: Instance level names: lower caseType level names: upper case

    UML tutorial Ileana Ober

    Association endEndpoint of an associationCharacterized by a set of properties contributing to the association definitionMultiplicity (ex: 1, 2..7, *, 4..* )Ordering ordered/unorderedVisibility +,-,#, ~Aggregation

    UML tutorial Ileana Ober

    Various kinds of associations (1/2)Regular associationComposition: one class is owned (composed in) the associated class Composition implies lifetime responsibility (based on association end multiplicities)

    Composition symbol

    UML tutorial Ileana Ober

    Various kinds of associations (2/2)Aggregationlight composition, semantics left open, to be accommodated to user needsAs it is, it has no particular meaning

    Further reading: F.Barbier, B.Henderson-Sellers, A.Le Parc-Lacayrelle, J.-M.Bruel: Formalization of the Whole-Part Relationship in the Unified Modeling Language, IEEE Transactions on Software Engineering, 29(5), IEEE Computer Society Press, pp. 459-470, 2003 aggregation symbol

    UML tutorial Ileana Ober

    More on associationsAssociations may be n-ary (n>2) Qualifiers partition the set of objects that may participate in an association

    UML tutorial Ileana Ober

    Association classAn association that is also a class. It defines a set of features that belong to the relationship itself and not any of the classifiers.

    association class symbol

    UML tutorial Ileana Ober

    Other elements of class diagramsInterface (definition and use)Comments

    UML tutorial Ileana Ober

    InterfaceDeclares set of public features and obligationsSpecifies a contract, to be fulfilled by classes implementing the interface

    Not instantiable

    Its specification can be realized by 0, 1 or several classesthe class presents a public facade that conforms to the interface specification (e.g. interface having an attribute does not imply attribute present in the instance)a class may implement several interfaces

    Interfaces hierarchies can be defined through inheritance relationships

    UML tutorial Ileana Ober

    Interface definition and use examples

    The class Satellite provides implementation for the 3 operations

    UML tutorial Ileana Ober

    Means to specify the interface contractInvariant conditionsPre and post conditions (e.g. on operations)Protocol specifications which may impose ordering restrictions on interactions through the interface for this one may use protocol state machines

    UML tutorial Ileana Ober

    TemplatesMech