
2019/6/10 Object-oriented Analysis and Design Object-oriented Analysis and Design Applying UML and Patterns Chap 16 An Introduction to Object-oriented Analysis UML Class Diagrams and Design and Iterative Development Part III Elaboration Iteration I – Basic2 Software Engineering Software Engineering 1 2 Object-oriented Analysis and Design Object-oriented Analysis and Design Common UML class diagram notation 1 Introduction Objective of this chapter Provide a reference for frequently used UML class diagram notation The UML includes class diagrams to illustrate classes, interfaces, and their associations. They are used for static object modeling Software Engineering Software Engineering 3 4 Object-oriented Analysis and Design ★ Object-oriented Analysis and Design Common UML class diagram notation 2 Design Class Diagram (DCD) The same UML diagram can be used in multiple perspectives In a conceptual perspective the class diagram can be used to visualize a domain model. Class diagram is used in a software or design perspective, called design class diagram (DCD) Domain Model Sale Register 1 Captures 1 time conceptual ... isComplete : Boolean perspective /total Register Sale Design Model ... 1 time isComplete : Boolean DCD ; software endSale () currentSale /total perspective enterItem (...) makePayment (...) makeLineItem (...) Software Engineering Software Engineering 5 6 1 2019/6/10 ★ Object-oriented Analysis and Design ★★ ★ Object-oriented Analysis and Design Classifier Ways to Show UML Attributes A UML classifier is "a model element that describes Ways to Show UML Attributes: behavioral and structure features". Attribute Text and Association Lines Classifiers can also be specialized. Attributes of a classifier are shown several ways: They are a generalization of many of the elements of the attribute text notation, such as currentSale : Sale. UML, including classes, interfaces, use cases, and actors. association line notation In class diagrams, the two most common classifiers are both together regular classes and interfaces. The full format of the attribute text notation is: visibility name : type multiplicity = default {property- string} Guideline: Attributes are usually assumed private if no visibility is given Software Engineering Software Engineering 7 8 Object-oriented Analysis and Design Object-oriented Analysis and Design Ways to Show UML Attributes 1 Ways to Show UML Attributes 2 Register Sale using the attribute text notation to currentSale : Sale ... the association name, common when drawing a indicate Register has domain model, is often excluded (though still legal) a reference to one ... ... when using class diagrams for a software Sale instance perspective in a DCD Register Sale 1 Captures-current-sale 1 Register Sale UP Domain Model OBSERVE : this style conceptual perspective id : Int time : DateTime visually emphasizes 1 ... ... the connection currentSale between these classes ... ... using the association notation to indicate UP Design Model Register Sale Register has a reference to one Sale instance DCD 1 id: Int time: DateTime software perspective currentSale ... ... Register Sale thorough and unambiguous , but some 1 currentSale : Sale ... people dislike the currentSale possible redundancy ... ... Attribute text versus association line notation for a UML attribute Software Engineering Software Engineering 9 10 Object-oriented Analysis and Design Object-oriented Analysis and Design Ways to Show UML Attributes 3 Ways to Show UML Attributes 4 Guideline: When showing attributes-as-associations, Guideline: When to Use Attribute Text versus follow the style in DCDs, which is suggested by the Association Lines for Attributes UML specification. (Fig 16.4 upper) Use the attribute text notation for data type objects and Guideline: when using class diagrams for a domain the association line notation for others. model do show association names but avoid navigation Both are semantically equal, but showing an association arrows, as a domain model is not a software perspective. line to another class box in the diagram (as in Figure 16.3) gives visual emphasis - it catches the eye, emphasizing the connection between the class of objects on the diagram. Software Engineering Software Engineering 11 12 2 2019/6/10 Object-oriented Analysis and Design Object-oriented Analysis and Design Ways to Show UML Attributes 5 Ways to Show UML Attributes 6 Register Sale applying the guideline How to Show Collection Attributes with Attribute Text 1 to show attributes as id: Int time: DateTime attribute text versus as currentSale and Association Lines ? association lines ... ... Register has THREE attributes: Store 1. id 1 2. currentSale address: Address public class Sale { phone: PhoneNumber 3. location location private List<SalesLineItem> lineItems = ... new ArrayList<SalesLineItem>(); // … public class Register { } private int id; } private Sale currentSale; private Store location; // … } Software Engineering Software Engineering 13 14 ★ ★ ★ Object-oriented Analysis and Design Object-oriented Analysis and Design Ways to Show UML Attributes 7 Operations and Methods 1 Operations Sale SalesLineItem visibility name (parameter-list) : return-type {property-string} time: DateTime ... Guideline:Assume the version that includes a return type. lineItems : SalesLineItem [1..*] or ... Guideline: Operations are usually assumed public if no visibility is lineItems : SalesLineItem [1..*] {ordered} shown. ... Example Two ways to show a collection attribute + getPlayer( name : String ) : Player {exception IOException} public Player getPlayer( String name ) throws IOException Sale SalesLineItem An operation is not a method. 1..* time: DateTime ... A UML operation is a declaration, with a name, parameters, lineItems return type, exceptions list, and possibly a set of constraints of ... {ordered, List} ... pre-and post-conditions. But, it isn't an implementation - rather, methods are notice that an association end can optionally also have a property string such as {ordered, List} implementation Software Engineering Software Engineering 15 16 Object-oriented Analysis and Design Object-oriented Analysis and Design Operations and Methods 2 Keywords 1 How to Show Methods in Class Diagrams? A UML keyword is a textual adornment to categorize a in interaction diagrams, by the details and sequence of model element. messages For example, the keyword to categorize that a classifier in class diagrams, with a UML note symbol stereotyped box is an interface is «interface». with «method» The «actor» keyword was used on p. 91 to replace the human stick-figure actor icon with a class box to model computer-system or robotic actors. Register «method» Guideline: When sketching UML - when we want speed, // pseudo-code or a specific language is OK ... public void enterItem( id, qty ) ease, and creative flow - modelers often simplify { endSale() ProductDescription desc = catalog.getProductDescription(id); enterItem(id, qty) keywords to something like '<interface>' or '<I>'. sale.makeLineItem(desc, qty); makeNewSale() } makePayment(cashTendered) Software Engineering Software Engineering 17 18 3 2019/6/10 ★ Object-oriented Analysis and Design Object-oriented Analysis and Design Keywords 2 Stereotypes, Profiles, and Tags Most keywords are shown in guillemet (« ») but some Stereotypes are shown in curly braces, such as {abstract}, which is a are shown with guillemets symbols constraint containing the abstract keyword. represents a refinement of an existing modeling concept and is defined within a UML profile In general, when a UML element says it can have a The UML predefines many stereotypes, such as «destroy» (used "property string“ - such as a UML operation and UML on sequence diagrams), and also allows user-defined ones. association end have - some of the property string terms Thus, stereotypes provide an extension mechanism in the UML will be keywords used in the curly brace format. Profiles a collection of related stereotypes, tags, and constraints to specializethe use of the UML for a specific domain or platform For example, UML profile for project management or for data modeling. Software Engineering Software Engineering 19 20 × Object-oriented Analysis and Design Object-oriented Analysis and Design Stereotypes Property and Property String In the UML, a property is "a named value denoting a characteristic of an element. A property has semantic declaring the stereotype using the stereotype impact." a tool will probably allow a popup to fill in the tag values, Some properties are predefined in the UML, such as UML extension once an element has been stereotyped with «authorship» relationship to a basic visibility - a property of an operation. UML metamodel term – Element Others can be user-defined. «authorship» Textual presentation approach «metaclass» «stereotype» «authorship» author = “craig” Element Authorship Square status = “tested” UML property string {name1=value1, name2=value2} ... author: String ... status : String such as {abstract, visibility=public}. Some properties are shown without a value, such as {abstract}; Stereotype declaration and use Software Engineering Software Engineering 21 22 Object-oriented Analysis and Design Object-oriented Analysis and Design Abstract Classes and Abstract Operations Constraint Abstract classes and operations can be shown either with Constraints an {abstract} tag (useful when sketching UML) or by Constraints may be used on most UML diagrams, but are especially common on
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages7 Page
-
File Size-