Introduction To UML And Design Patterns

3y ago
50 Views
6 Downloads
1.28 MB
13 Pages
Last View : 11d ago
Last Download : 3m ago
Upload by : Gideon Hoey
Transcription

A Software Life-cycle Model Which part will we talk about today?2MaintenanceValidate Requirements, Verify SpecificationIntroduction to UMLand Design PatternsAcceptance TestRequirements(Release testing)Verify System DesignSystem DesignSystem Testing(Architecture,High-level Design)(Integration testing of modules)Module DesignDF14900 Software EngineeringCUGS(Program Design,Detailed Design)2011Verify Module DesignModule Testing(Integration testing of units)Verify ImplementationImplementationUnit testingof Units (classes, procedures,functions)Christoph Kessler and Kristian SandahlDepartment of Computer and Information ScienceLinköping University, SwedenProject Management, Software Quality Assurance (SQA), Supporting Tools, EducationPart IModeling Structure:Classes and ObjectsThe goals of module design3Part II:Short Introduction to Design Patterns§ Contribute to quality, eg:PerformanceUsabilityReliability.Part III:Behavioral Modeling with UMLState Machines, Sequence Diagrams,Use case diagrams, Activity DiagramsPart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and Objects5Part IModeling Structure with UMLClasses and ObjectsPart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design Patterns4AgendaEsp., Classes and ObjectsSeparation of concernTestabilityUnderstandabilityPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Part I:Structural Modeling with UML§ Provide the expected function§ Prepare for change:Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Part IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Modeling as a Design Technique§§§§Testing a physical entity before building itCommunication with customersVisualizationReduction of complexity§ Models supplement natural language§ Models support understanding, design, documentation§ Creating a model forces you to take necessary designdecisions§ UML is now the standard notation for modeling software.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.1

UML: Different diagram typesfor different views of softwareLiterature on UML§ Official standard documents by OMG:www.omg.org, www.uml.org§ Current version is UML 2.0 (2004/2005)§ OMG documents:UML Infrastructure, UML Superstructure§ Books:Modeling (logical) structure of software:§ Static view: Class diagram§ Design view: Structure diagr., collaboration d., component d.§ Use case view: Use case diagramModeling behavior of software:§ Activity view: Activity diagram§ State machine view: State machine diagram§ Interaction view: Sequence diagram, communication diagramPfleeger: Software Engineering 3rd ed., 2005(mostly Chapter 6)Rumbaugh, Jacobson, Booch:The Unified Modeling Language Reference Manual, Second Edition,Addison-Wesley 2005Blaha, Rumbaugh: Object-Oriented Modeling and Design with UML,Second Edition, Prentice-Hall, 2005.Stevens, Pooley: Using UML: Software Engineering with Objects andComponents, 2nd edition. Addison-Wesley, 2006And many others Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsModeling physical structure of software§ Deployment view: Deployment diagramModeling the model, and extending UML itself§ Model management view: Package Diagram§ ProfilesPart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and Objects9A Single ClassPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Relationships (1/6) - overview and intuition- Association10AssociationClass name(with navigability)attributesMultiplicity1 exactly one0.1 Zero or one* Zero or more(same as 0.*)2.8 Between 2 and 8operationsvisibility public- private# protected packagePart IModeling Structure:Classes and ObjectsParameterPart IIShort Introductionto Design PatternsReturn typePart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsRelationships (1/6) - overview and intuition- Association11Part IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Relationships (1/6) - overview and intuition- Associationclass4Both representations arealmost equivalentattributes12Explicitly show that navigationis not allowedNavigation - mycar can reach thewheels, but not the oppositerole nameobjectswheel1directed associationmycar{ordered} {unordered}{unique}{nonunique}Default is unordered,uniquePart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.wheel2mycar has links to 4wheelsPart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design Patternswheel4wheel3Part IIIModeling Behavior:State Machines etc.2

Relationships (1/6) - overview and intuition- Association13Relationships (1/6) - overview and intuition- Association4What does it mean to have a * here?144What if we have multiplicity 1 instead?"*"Associations are the "glue" that ties a systemtogether"1"association instance linkmycar1mycar1mycar3mycar2A wheel can only be likedto one car instancewheel1 wheel2 wheel3 wheel4Part IModeling Structure:Classes and ObjectsA wheel can be linked to morethan one car instancePart IIShort Introductionto Design Patternsmycar1mycar2An association describes a relation betweenobjects at run-time.wheel1 wheel2 wheel3 wheel4wheel1 wheel2 wheel3 wheel4Part IIIModeling Behavior:State Machines etc.Relationships (2/6) - overview and intuition- AggregationAssociation(with ar1,wheel3),(mycar1,wheel4)}Part IModeling Structure:Classes and Objects15Part IIIModeling Behavior:State Machines etc.Part IIShort Introductionto Design PatternsRelationships (2/6) - overview and intuition- Aggregation16A major source of confusionCommon vague interpretations: "owns a" or "part of""A" has a reference(s) toinstance(s) of "B". Alternative: attributes4AggregationWhat does this mean? What is thedifference to association?Inconsistency and misunderstandingsVague definitionsAggregation was added to UML withlittle semantics. Why?Jim Rumbaugh"Think of it as a modeling placebo"Recommendation: - Do not use it in your models.- If you see it in other's models, ask them what they actually mean.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Relationships (3/6) - overview and intuition- CompositionAssociation(with navigability)Aggregation17Part IIIModeling Behavior:State Machines etc.Part IIShort Introductionto Design PatternsPart IModeling Structure:Classes and ObjectsRelationships (3/6) - overview and intuition- Composition18Any difference to association?"A" has a reference(s) toinstance(s) of "B". Alternative: attributes14Avoid it to avoid misunderstandingsYes! First, multiplicity must be 1 or 0.1. An instance can only have one owner.CompositionBut, isn't this equivalent to what weshowed with associations?1mycar14mycar2Well, in this case.wheel1 wheel2 wheel3 wheel4Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.3

Relationships (3/6) - overview and intuition- Composition19Using composition.1Relationships (3/6) - overview and intuition- Composition20Using composition.4121421Can mycar1 and mybike1share the same wheels?Ok for wheels to be part ofmycar1 or mybike1mycar1wheel1 wheel2 wheel3 wheel4Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design Patternswheel1 wheel2 wheel3 wheel4wheel5 wheel6Part IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsRelationships (3/6) - overview and intuition- CompositionUsing associations.NO!Not with composition!mycar1mybike121Part IIShort Introductionto Design PatternsRelationships (4/6) - overview and intuition- Generalization(Note the difference. The diamond is removed.)4Association22"A" has a reference(s) toinstance(s) of "B". Alternative: attributes12Can mycar1 and mybike1 sharethe same wheels this time?Yes! Associations do nothave a "no sharing"rule.mycar1Key concepts "No sharing" rule The owner is responsible for managingits parts,e.g.allocation and deallocation.wheel5wheel6Part IIIModeling Behavior:State Machines etc.(with navigability)1mybike1AggregationAvoid it to avoid misunderstandingsCompositionAn instance of "B" is part of an instance of "A",where the former is not allowed to be shared.Generalizationmybike1However, in this case it is astrange model.wheel1 wheel2 wheel3 wheel4Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design Patternswheel5 wheel6Part IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsRelationships - (4/6) overview and intuition- GeneralizationClass with code forthe drive()1. Inheritanceoperation relation implementation23Part IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Relationships - (5/6) overview and intuition- RealizationVisible Type: Vehicle.Instance of: MotorCycle.Can we drive()? Can we reverse()?AssociationVisible Type: Car.Instance of: CarCan we drive()? Can we reverse()?AggregationAvoid it to avoid misunderstandingsVisible Type: Vehicle.Instance of: CarCan we drive()? Can we reverse()?CompositionAn instance of "B" is part of an instance of "A",where the former is not allowed to be shared.Generalization1) "A" inherits all properties and operations of "B".2) An instance of "A" can be used where ainstance of "B" is expected.(with navigability)reverse() is not visible!Overrides drive()An instance of a class can have many types (subtyping) polymorphismInherits the code fordrive(). Newoperation reverse()Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design Patterns24"A" has a reference(s) toinstance(s) of "B". Alternative: attributesRealization2. Subtyping relation on interfacesstatic typing: safe substitutionPart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.4

Relationships - (5/6) overview and intuition- Realization25Relationships - (5/6) overview and intuition- RealizationRealization provides a specified interfaceWhat is the difference between an interfaceand an abstract class?Can we create an instance ofVehicle? Yes! It is concrete.AnotherVehicleRealization drive() open()SpecifierInterfaceInterfaceCan we create an instance ofAnotherVehicle? No!Implementation(no implementation)Correct?Must implementthe interfaceProvides the DoorinterfacePart IModeling Structure:Classes and ObjectsAbstract classNon of them can be instantiatedCannot contain implementationCan (but need not to) containimplementationAbstract class(Italic)An abstract class with only abstract operations is conceptually the same as an interfaceAbstract operationPart IIIModeling Behavior:State Machines etc.Part IIShort Introductionto Design PatternsPart IModeling Structure:Classes and ObjectsRelationships - (6/6) overview and intuition- Realization27(with navigability)Part IIIModeling Behavior:State Machines etc.Part IIShort Introductionto Design PatternsRelationships - (6/6) overview and intuition- Dependency"A" has a reference(s) toinstance(s) of "B". Alternative: d it to avoid misunderstandingsCompositionAn instance of "B" is part of an instance of "A",where the former is not allowed to be shared.Generalization1) "A" inherits all properties and operations of "B".2) An instance of "A" can be used where ainstance of "B" is expected.Realization"A" provides an implementation of the interfacespecified by "B".clientsupplierDependencyPart IModeling Structure:Classes and ObjectsPart IIIModeling Behavior:State Machines etc.Part IIShort Introductionto Design PatternsPart IModeling Structure:Classes and ObjectsRelationships - (6/6) overview and intuition- Dependency29Part IIIModeling Behavior:State Machines etc.Relationships - overview and intuitionAssociationUML as sketch§§§Part IIShort Introductionto Design Patterns(with navigability)Help to communicate some important aspect of systemCommon media: whiteboardReverse engineering can be veryIn documents: focus on communication compared touseful to see dependenciescompleteness30"A" has a reference(s) toinstance(s) of "B". Alternative: attributesAggregationAvoid it to avoid misunderstandingsCompositionAn instance of "B" is part of an instance of "A",where the former is not allowed to be shared.Generalization1) "A" inherits all properties and operations of "B".2) An instance of "A" can be used where ainstance of "B" is expected.Realization"A" provides an implementation of the interfacespecified by "B".Dependency"A" is dependent on "B" if changes in thedefinition of "B" causes changes of "A".between classes and modules!UML as blueprintForward engineeringUMLmodelRound-trip engineeringProgrammingCodeReverse engineeringUML as programming languageUMLmodelPart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.CompileExecutableCodePart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.5

Class model with inheritanceand abstract classesClasses and objectsClasses:Abstract class(cannot be instantiated,only mer0.*0.*CupOfCoffeepay( c: coin )Objects:c1: CupOfCoffeeIndividualCustomergetCup()Part IModeling Structure:Classes and ObjectsKristian:CoffeeCustomerPorterpay() method isinherited fromCoffeeCustomergetCan()Part IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.c2: CupOfCoffeePart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.34Reasoning about an arbitrary objectLike fee:CupOfCoffeebuys: CupOfCoffeePart IIShort Introduction to Design Patterns.or simply like this:: CoffeeCustomerPart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.TAPESTRY OF LIGHT AND DARKChristopher AlexanderCreate alternating areas of light and darkthroughout the building, in such a way thatpeople naturally walk toward the light,whenever they are going to important places:seats, entrances, stairs, passages, places ofspecial beauty, and make other areas darker, toincrease the contrast.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.6

Software Design PatternsA Design Pattern is a standard solution for a standarddesign problem in a certain context.Goal: reuse design information“A pattern involves a general description of a recurring solution to a recurringproblem with various goals and constraints. It identifies more than asolution, it also explains why the solution is needed.“ (James Coplien)“. describes a problem which occurs over and over again in our environment,and then describes the core of the solution to that problem, in such a waythat you can use this solution a million times over, without ever doing itthe same way twice” (Christopher Alexander)Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Example: FacadePart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Example: FacadeFacadePart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.How to describe design patterns?Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Pattern Catalog in Gamma et al. 1996:The GoF book describes each patternusing the following attributes:The name to describes the pattern,its solutions and consequencesin a word or twoThe problem describes when to apply the pattern:intent, motivation, applicabilityThe solution describes the elements that make up the design(structure with participants), their relationships, responsibilities,and collaborations/interactionsThe consequences are the results and trade-offs in applyingthe patternAlso: implementation notes, known uses, related patterns.All examples in C and SmalltalkRemark: Patterns exist also beyond the OO world Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.7

FacadeFacadeIntentApplicabilityProvide a unified interface to a set of interfaces in a subsystem.Facade defines a higher-level interface that makes the subsystemeasier to use.Use the Facade pattern when:§ you want to provide a simple interface to a complex subsystem.This makes subsystems more reusable and easier to customize.§ there are many dependencies between clients and theimplementation classes of an abstraction.Introduce a facade to decouple the subsystem from othersubsystems, thereby promoting subsystem independence andportability.§ you want to layer your subsystems.Use a facade to define an entry point to each subsystem level.MotivationStructuring a system into subsystems helps reduce complexity.A common design goal is to minimize the communication anddependencies between subsystems. example Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.FacadePart IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Observer50%Consequences40%50%30%40%The Facade pattern offers the following benefits:1. It shields clients from subsystem components, thereby reducingthe number of objects that clients deal with and makingsubsystem easier to use.2. It promotes weak coupling between subsystem and its clients.Weak coupling lets you vary the components of the subsystemwithout affecting its clients.3. It doesn't prevent applications from using subsystem classes ifthey need to.Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Observer10%20%0%10%abc0%abca 10%b 30%c 40%Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.Observer, structureSubjectApplicability§ When an abstraction has two aspects, one dependent on the other.§ When a change to one object requires changing others.§ When an object should be able to notify other objects without makingassumptions about who these objects are.Part IModeling Structure:Classes and Objects20%30%Part IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines tateobserverStategetState()setState()update()Part IModeling Structure:Classes and ObjectsPart IIShort Introductionto Design PatternsPart IIIModeling Behavior:State Machines etc.8

Observer, collaborationsObse

to Design Patterns Part III Modeling Behavior: State Machines etc. Literature on UML §Official standard documents by OMG: www.omg.org, www.uml.org §Current version is UML 2.0 (2004/2005) §OMG documents: UML Infrastructure, UML Superstructure §Books: Pfleeger: Software Engineering 3rd ed., 2005 (mostly Chapter 6) Rumbaugh, Jacobson, Booch:

Related Documents:

UML unifies a number of visual design methodologies in software engineering, business modeling and management, database design, and others. UML Class diagrams are a subset of UML that is suitable for conceptual modeling of classes and databases Most used type of UML diagrams UML is also a graphic language for modeling dynamic aspects of a

18/12/06 Introduction à UML 4 Le méta-modèle UML UML : langage permettant de créer des modèles, UML : modélisation des modèles, un méta-modèle. Le méta-modèle UML est en 4 couches: (M3) métamétamodèle : (concept de métaclasse) Définit le langage pour la spécification des metamodèles, (M2) métamodèle : (concept de classe)

OOAD with UML Object Oriented Analysis and Design Using the UML . 2 UML Applied - Object Oriented Analysis and Design using the UML . . Objects 23 Terminology 24 The Object Oriented Strategy 24 Summary 25 AN OVERVIEW OF THE UML 26 The Use Case Diagram 27 The Class Diagram 28

Praise for UML Distilled “UML Distilled remains the best introduction to UML notation. Martin’s agile and pragmatic approach hits the sweet spot, and I wholeheartedly recommend it!” —Craig Larman Author of Applying UML and Patterns “Fowler cuts through the complexity of UML to get users started quickly.”

diagramme de classes stereotype NomClasseAbstraite from nomPaquetage - attributPrivate : Type valeur # attributProtected : Type attributPublic . [UML 1.3] OMG UML Specification v. 1.3, OMG doc# ad/06-08-99 [UML 1.4] OMG UML Specification v. 1.4, UML Revision Task Force recommended final draft,

To understand the UML, you need to form a conceptual model of the language, and this requires learning three major elements: Basic building blocks of the UML Rules Common Mechanisms in the UML Basic building blocks of the UML: Vocabulary of the UML can be defined 1. Things 2. Relationships 3. Diagrams Things in the UML

Visual Paradigm for UML Quick Start Page 5 of 30 Starting Visual Paradigm for UML You can start Visual Paradigm for UML by selecting Start Menu Visual Paradigm Visual Paradigm for UML 7.1 Enterprise Edition. Importing license key 1. After you enter VP-UML, you will be asked to provide license key in License Key Manager.

The standards are neither curriculum nor instructional practices. While the Arizona English Language Arts Standards may be used as the basis for curriculum, they are not a curriculum. Therefore, identifying the sequence of instruction at each grade - what will be taught and for how long- requires concerted effort and attention at the local level. Curricular tools, including textbooks, are .