軟件需求分析英文課件:Chap 2-Intro to UML (2)_第1頁
軟件需求分析英文課件:Chap 2-Intro to UML (2)_第2頁
軟件需求分析英文課件:Chap 2-Intro to UML (2)_第3頁
軟件需求分析英文課件:Chap 2-Intro to UML (2)_第4頁
軟件需求分析英文課件:Chap 2-Intro to UML (2)_第5頁
已閱讀5頁,還剩140頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、Chapter 2 UML Overview2.1 Overview of the UML2.2 A Conceptual Model of the UML2.3 Structural Modeling2.4 Behavioral Modeling2.5 Simple Example Hello World2.1 Overview of the UMLWhat is UML A Brief History of UMLOMG UML SpecificationUML SemanticsWhat Is the UML?UML = Unified Modeling LanguageThe UML

2、is a language forVisualizingSpecifyingConstructingDocumentingthe artifacts of a software-intensive system.The UML combines the best of the best from:Data Modeling concepts (ER)Business Modeling (work flow)Object ModelingComponent ModelingIt can be uses with all processes ,throughout the development

3、life cycle, and across different implementation technologiesHistory of the UMLWeb - June 1996 OOPSLA 95PublicFeedbackOMG Acceptance, Nov 1997Final submission to OMG, Sept 1997First submission to OMG, Jan 1997UML 1.0UML partnersUML 1.1UML 1.4UML 2.0Planned minor revision (2000)Planned major revision

4、(2001)UML 1.3Current minor revision 1999Contributions to the UML 1. UML Semantics 2. UML Notation Guide 3. UML Example Profiles 4. UML Model Interchange 5. Object Constraint Language Specification A. UML Standard Elements B. GlossaryOMG UML SpecificationUML SemanticsUML Semantics2.2 A Conceptual Mod

5、el of the UMLBuilding Blocks of the UML1) Things in the UML2) Relationships in the UML3) Diagrams in the UMLCommon Mechanisms in the UML1) Specifications2) Adornments3) Common divisions4) Extensibility mechanismsBuilding Blocks of the UMLBuilding Blocks of the UMLThe vocabulary of the UML encompasse

6、s three kinds of building blocks:Things: the abstractions that are first-class citizens in a model; Relationships: relationships tie these things together;Diagrams: diagrams group interesting collections of things.1) Things in the UMLThere are four kinds of things in the UML:Structural things: class

7、, interface, collaboration, use case, active class, component, nodeBehavioral things: interaction, state machine, activityGrouping things: packageAnnotational things: noteThese things are the basic object-oriented building blocks of the UML.Structural thingsthe nouns of UML models.the mostly static

8、parts of a model, either conceptual or physicalCollectively, the structural things are called classifiers Seven kinds: Logic view: class, interface, collaboration, Requirement view: use caseProcess view: active classImplementation view: component, node Structural things1.Classa description of a set

9、of objects that share the same attributes, operations, relationships, and semantics. A class implements one or more interfaces.2. Interface a collection of operations that specify a service of a class or component. An interface defines a set of operation specifications but never a set of operation i

10、mplementations.3. Collaborationsdefines an interaction and is a society of roles and other elements that work together to provide some cooperative behavior thats bigger than the sum of all the elements. Structural things4. Use casea description of set of sequence of actions that a system performs th

11、at yields an observable result of value to a particular actor. A use case is used to structure the behavioral things in a model. A use case is realized by a collaboration.5. active classa class whose objects own one or more processes or threads and therefore can initiate control activity.6. Componen

12、ta physical and replaceable part of a system that conforms to and provides the realization of a set of interfaces.Structural things7. Nodea physical element that exists at run time and represents a computational resource, generally having at least some memory and, often, processing capability.There

13、are also variations on these sevensuch as actors, signals, and utilities (kinds of classes)processes and threads (kinds of active classes)applications, documents, files, libraries, pages, and tables (kinds of components)Behavioral ThingsBehavioral things are the dynamic parts of UML models. Two prim

14、ary kinds of behavioral thingsInteractiona behavior that comprises a set of messages exchanged among a set of objects within a particular context to accomplish a specific purposestate machinea behavior that specifies the sequences of states an object or an interaction goes through during its lifetim

15、e in response to events, together with its responses to those events.Grouping ThingsGrouping things are the organizational parts of UML models. These are the boxes into which a model can be decomposed.package Packages are the basic grouping things with which you may organize a UML model. There are a

16、lso variations, such as frameworks, models, and subsystems (kinds of packages).Dependency relationshipA(from packageA)B(from packageB)PackageAPackageBAnnotational ThingsAnnotational things are the explanatory parts of UML models. These are the comments you may apply to describe, illuminate, and rema

17、rk about any element in a model.Notesthe one basic annotational thing you may include in a UML model. use notes to adorn diagrams with constraints or comments that are best expressed in informal or formal text.2) Relationships in the UMLThere are four kinds of relationships in the UML1.Association2.

18、 Dependency3. Generalization4. RealizationAssociationAn association is a structual relationship that describes a set of links, a link being a connection among objectsDependencyAn dependency is a semantic relationship between two things in which a change to one thing (the independent thing) may affec

19、t the semantics of the other things (the dependent thing )GeneralizationA generalization is a specialization/generalization relationship in which object of the specialized element (the child) are substitutable for objects of the generalized element (the parent). In this way , the child shares the st

20、ructure and the behavior of the parentsRealizationA realization is a semantic relationship between classifiers, wherein one classifier specifies a contract that another classifier guarantees to carry out3) Diagrams in the UMLA diagram is the graphical presentation of a set of elementsDeploymentDiagr

21、amsuse-caseDiagramsScenarioDiagramsScenarioDiagramsSequenceDiagramsStateDiagramsStateDiagramsStateDiagramsComponentDiagramsComponentDiagramsComponentDiagramsModelsStateDiagramsStateDiagramsObjectDiagramsScenarioDiagramsScenarioDiagramsCollaborationDiagramsActivityDiagramsStateDiagramsStateDiagramsCl

22、assDiagramsClass diagram - shows a set of classes, interfaces, and collaborations and their relationships.Component diagram - shows the organizations and dependencies among a set of components.Deployment diagram - shows a set of nodes and their relationships.Diagrams in the UML1.xModeling Requiremen

23、ts Modeling BehaviorModeling StructureLogic ViewPhysical ViewUse Case diagram - organizing and modeling the behaviors of a system.Sequence diagram - emphasizes the time ordering of messages.Collaboration diagram - emphasizes the organization of the objects that participate in an interaction.Statecha

24、rt diagram - emphasizes the event-ordered behavior of an object.Activity diagram- emphasizes the flow of control among objects.Projection of InteractionProjection of state machineCommon Mechanisms in the UMLCommon Mechanisms in the UMLUML is made simpler by the presence of four common mechanisms tha

25、t apply consistently throughout the language1) Specifications2) Adornments3) Common divisions4) Extensibility mechanisms1) SpecificationsThe UML is more than just a graphical language. Rather, behind every part of its graphical notation there is a specification that provides a textual statement of t

26、he syntax and semantics of that building block.For example, behind a class icon is a specification that provides the full set of attributes, operations (including their full signatures), and behaviors that the class embodies; visually, that class icon might only show a small part of this specificati

27、on.Use the UMLs graphical notation to visualize a system; Use the UMLs specification to state the systems details.2) AdornmentsEvery element in the UMLs notation starts with a basic symbol, to which can be added a variety of adornments specific to that symbol.For example A classs specification may i

28、nclude other details, such as whether it is abstract or the visibility of its attributes and operations. Many of these details can be rendered as graphical or textual adornments to the classs basic rectangular notation.3) Common divisionsIn modeling object-oriented systems, the world often gets divi

29、ded in at least a couple of waysThe division of class and objectA class is an abstraction; an object is one concrete manifestation of that abstractionAlmost every building block in the UML has this same kind of class/object dichotomy. For example, use cases and use case instances, components and com

30、ponent instances, nodes and node instancesThe separation of interface and implementationAn interface declares a contract, and an implementation represents one concrete realization of that contract, responsible for faithfully carrying out the interfaces complete semanticsAlmost every building block i

31、n the UML has this same kind of interface/ implementation dichotomy. For example, use cases and the collaborations that realize them, as well as operations and the methods that implement themCommon divisions4) Extension mechanismThe UML is opened-ended, making it possible for you toextend the langua

32、ge in controlled waysStereotypeTagged valueConstraintExtension mechanism - StereotypesA stereotype is an extension of the vocabulary of the UML, allowing you to create new kinds of building blocks similar to existing ones but specific to your problem.Stereotypes must be based on certain existing typ

33、es or classes in the metamodel. Stereotypes may extend the semantics, but not the structure of pre-existing types and classes. Certain stereotypes are predefined in the UML, others may be user defined.StereotypesStereotypes define a new model element in terms of another model element.Sometimes, you

34、need to introduce new things that speak the language of your domain and look like primitive building blocks.Represented with name in guillemets or as a different icon Shape ShapeExtension mechanism - Tagged ValuesMany kinds of elements have detailed properties that do not have a visual notation. In

35、addition, users can define new element properties using the tagged value mechanism.A tagged value is an extension of the properties of a UML element, allowing you to create new information in that elements specification. A tagged value is a keyword-value pair that may be attached to any kind of mode

36、l element The keyword is called a tag. Tagged Values - ExampleCommon examples of tagged values are:Author = (Dave,Ron)Version Number = 3Location = d:javaumlexamplesLocation = Node: Middle TierMyClassVersion = 1.02Extension mechanism - ConstraintA constraint is an extension of the semantics of a UML

37、elements, allowing you to add new rules or to modify existing ones. Constraints may be written as free-form text. If you want to specify your semantics more precisely, you can use the UMLs Objec Constraint Language(OCL).Common Modeling Techniques1) Modeling Comments - use notes 2) Modeling New Build

38、ing Blocks - use stereotype.3) Modeling New Properties - use tagged values.4) Modeling New Semantics - use constraint2.3 Structural ModelingClass DiagramComponent DiagramDeployment DiagramClass DiagramClass Diagram1) Class2) Class Diagram3) Generalization4) Realization5) Dependency6) Association1) C

39、lassA class is a description of a set of objects that share the same attributes, operations, relationships, and semantics.A class is represented using a compartmented rectangleObjectsProfessor SmithProfessor JonesProfessor MellonAttributesOperations: ProfessorProfessorClark : ProfessorProfessorClark

40、Class Name OnlyObject Name OnlyClass and Object NameRepresenting ObjectsAn object is represented as rectangles with underlined namesProfessor Clarka + b = 10Advanced ClassesClassifiersVisibilityScopeAttributesOperationsTemplate ClassesUtility ClassesAdvanced Classes ClassifierA class is a descriptio

41、n of a set of objects that share the same attributes, operations, methods, relationships, and semanticsIn general, those modeling elements that can have instances are called classifiersA classifier has structural features (in the form of attributes), as well as behavioral features (in the form of op

42、erations). Every instance of a given classifier shares the same features.In UML, Classifier include:class, interface, component, node, use casesubsystem, signal, datatypeThe visibility of a classifiers attributes and operations specifies whether it can be used by other classifierVisibility is used t

43、o enforce encapsulationMay be public, protected, or privateAdvanced Classes VisibilityAdvanced Classes ScopeThe owner scope of a classifiers attributes/operations attribute/operation:Instance: Each instance of the classifier holds its own value for the feature.Classifier:There is just one value of t

44、he feature for all instances of the classifier.Classifier scope is denoted by underlining the attribute/operation nameNote: Classifier scoped maps to what C+ calls static attributes/operationsThe structure of a class is represented by its attributesAttributes may be found by examining class definiti

45、ons, the problem requirements, and by applying domain knowledgeThere are three defined properties that you can use with attributes:1. changeable2. addOnly3. frozen Note: The frozen property maps to const in c+Advanced Classes AttributesThe behavior of a class is represented by its operationsoperatio

46、ns may be found by examining interaction diagramsAdvanced Classes OperationsA class definition which defines other classesOften used for container classesSome common container classes: sets, lists, dictionaries, stacks, queues, Advanced Classes Template classesExampleAdvanced Classes Template classe

47、s Advanced Classes Utility ClassesUtility - UML standard elements, specifies a class whose attributes and operations are all class scopedWhat is a Utility Class?Utility is a class stereotypeUsed for a class that contains a collection of free subprogramsWhy use it?To provide services that may be (re)

48、useful in a variety of contextsTo wrap non object-oriented libraries or applications2) Class DiagramClass diagram shows a set of classes, interfaces, and collaborations and their relationshipsClass diagrams contain:Classes, interfaces, collaborations. Dependency, generalization, and association rela

49、tionshipsCaptures the vocabulary of a systemBuilt and refined throughout developmentPurposeName and model concepts in the systemSpecify collaborationsSpecify logical database schemasDeveloped by analysts, designers, and implementers2) Class Diagram - Purpose3) Relationships: GeneralizationA relation

50、ship among classes where one class shares the structure and/or behavior of one or more classesDefines a hierarchy of abstractions in which a subclass inherits from one or more superclassesSingle inheritanceMultiple inheritancean “is-a-kind of” relationshipEmployeeManagerEngineerGeneralization relati

51、onshipEmployee is a generalization of Engineers and Managers.Engineer is a specialization of Employee.Manager is a kind of Employee.Engineers and Managers inherit the Employee interface (and in this case, some implementation too).Generalization - Exampleclass Employee .;class Manager : public Employ

52、ee .;class Engineer : public Employee ;. class Employee .class Manager extends Employee .class Engineer extends Employee Example: HelloWorld.java import java.applet.Applet;import java.awt.Graphics; public class HelloWorld extends Applet public void paint(Graphics g) g.drawString(Hello World!, 50, 25

53、); HelloWorld paint()AppletGraphicsGeneralization relationship4) Relationships: RealizationOne classifier serves as the contract that the other classifier agrees to carry outShapeTubePyramidCubeShapedraw()move()scale()rotate()TubePyramidCubeCanonical (Class/Stereotype) RepresentationElided/Iconic Re

54、presentation(“l(fā)ollipop”)Realization relationshipRealization - ExampleCircleShapeinterface Shape public void draw() ; class Circle implements Shape public void draw() . class Shape public: virtual void draw() = 0 ; ;class Circle : public Shape public: void draw() . ; ClientSupplierPackageClientPackag

55、eSupplierPackageClientSupplierClassDependency relationshipDependency relationshipComponent5) Relationships: DependencyA relationship between two model elements where a change in one may cause a change in the otherNon-structural, “using” relationshipDependency ExampleProfessorCourseclass Professor pu

56、blic void teach(Course c) . .class Professor public void teach() Course c = new Course(); . .Example: HelloWorld.java import java.applet.Applet;import java.awt.Graphics; public class HelloWorld extends Applet public void paint(Graphics g) g.drawString(Hello World!, 50, 25); HelloWorld paint()AppletG

57、raphicsDependency relationship6) Relationship AssociationThe semantic relationship between two or more classes that specifies connections among their instances A structural relationship, specifying that objects of one thing are connected to objects of anotherCourseStudentScheduleProfessorUniversityE

58、mployerEmployeeRole NamesWorks forAssociationAssociation Name What Is an Association? A exampleclass CatalogueEntry private string name; private int number; private double cost; public double getCost () return cost; class Part private CatalogueEntry entry; public double cost () return entry.getCost(

59、); CatalogueEntry screw= new CatalogueEntry (“screw”, 28834, 0.02); Part screw1 = new Part(screw) ; screw1.cost();Adornments that apply to associationsPersonCompanynn-employer-employeejobnnAssociation NameRole NamesAn association name: to describe the nature of the relationship.When a class particip

60、ates in an association, it has a specific role that it plays in that relationship. A role is just the face the class at the near end of the association presents to the class at the other end of the association.Adornments that apply to associations.The multiplicity of an associations role: to state h

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論