60-322 Object-Oriented Analysis and Design Feb 25, 2009.

Slides:



Advertisements
Similar presentations
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Advertisements

Object-Oriented Analysis and Design CHAPTERS 15: UML INTERACTION DIAGRAMS 1.
Inheritance Inheritance Reserved word protected Reserved word super
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
UML Class Diagram. UML Class Diagrams2 Agenda What is a Class Diagram? Essential Elements of a UML Class Diagram Tips.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Chapter 16. Fig Fig Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.
UML Class Diagram and Packages Written by Zvika Gutterman Adam Carmi.
Design Patterns in Java Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Chapter 15 Interaction Diagrams. Most Common Sequence Diagram Communication Diagram Sequence Diagrams illustrate interactions between classes of a program.
Advanced Object-Oriented Programming Features
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
Component and Deployment Diagrams
Object-Oriented Analysis and Design
Objectives Explain the purpose and objectives of object- oriented design Develop design class diagrams Develop interaction diagrams based on the principles.
Sept Ron McFadyen1 Extend Relationship.
Designing with Interaction and Design Class Diagrams Chapters 15 & 16 Applying UML and Patterns Craig Larman With some ideas from students in George Blank’s.
CS 494 Adv. SW Design and Development
Object-Oriented Analysis and Design
Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative Development Part III Elaboration Iteration I – Basic1.
Relationships. In the Interaction diagrams, we began to look at how classes communicate with one another. Now, we'll focus on the relationships between.
CSSE 374: Design Class Diagrams Steve Chenoweth Office: Moench Room F220 Phone: (812) These slides and others.
Systems Analysis and Design in a Changing World, Fifth Edition
Chapter 18 Object Design Examples with GRASP. Objectives Design use case realizations –A use-case realization describes how a particular use case is realized.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
Systems Analysis and Design in a Changing World, 3rd Edition
Object-Oriented Analysis and Design Fall 2009.
Design Class Diagrams (DCDs)
Chapter 16 Applying UML and Patterns Craig Larman
1 Class Diagrams: The Essentials. 2 Terms and Concepts A class is... The most important building block of any object-oriented system. A description of.
© 2005 Prentice Hall9-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Drawing System Sequence Diagrams
Object-Oriented Analysis and Design Feb 11, 2009.
Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Design Model Lecture p6 T120B pavasario sem.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
Inheritance. Inheritance is a fundamental object-oriented design technique used to create and organize reusable classes Chapter 8 focuses on: deriving.
Chapter 8 Specialization aka Inheritance. 2 Inheritance  Review of class relationships  Uses – One class uses the services of another class, either.
Object-Oriented Analysis and Design Week 11, 2009.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Chapter 16: UML Class Diagrams
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Chapter 16 UML Class Diagrams.
OO Methodology Elaboration Phase Iteration 1- Part 3.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
TK2023 Object-Oriented Software Engineering CHAPTER 11 CLASS DIAGRAMS.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
BTS430 Systems Analysis and Design using UML Design Class Diagrams (ref=chapter 16 of Applying UML and Patterns)
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Object Oriented Analysis & Design By Rashid Mahmood.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
11 Systems Analysis and Design in a Changing World, Fifth Edition.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
Object Design Examples with GRASP
Design Class Diagrams
Chapter 16 UML Class Diagrams.
GRASP: Visibility and Design
Inheritance and Polymorphism
Unified Modeling Language
Design Class Diagrams
Sequence Diagrams Lecture 6.
Class Diagrams.
Chapter 16 UML Class Diagrams
Object Oriented System Design Class Diagrams
Design Model: Creating Design Class Diagrams
Presentation transcript:

Object-Oriented Analysis and Design Feb 25, 2009

Feb 11, One of the compartments of the UML class box shows the signatures of operations. The preferred format of the operation syntax is: visibility name (parameter-list) : return-type {property-string} Guideline: Operations are usually assumed public if no visibility is shown. The property string contains arbitrary additional information, such as exceptions that may be raised, if the operation is abstract, and so forth. Operations and Methods

Feb 11, In addition to the official UML operation syntax, the UML allows the operation signature to be written in any programming language, such as Java, assuming the reader or tool is notified. For example, both expressions are possible: + getPlayer( name : String ) : Player {exception IOException} public Player getPlayer( String name ) throws IOException Operations and Methods

Feb 11, An operation is not a method. A UML operation is a declaration, with a name, parameters, return type, exceptions list, and possibly a set of constraints of pre-and post-conditions.operation But, it isn't an implementation - rather, methods are implementations. When we explored operation contracts, in UML terms we were exploring the definition of constraints for UML operations.operation contractsUML operations Operations and Methods

Feb 11, A UML method is the implementation of an operation; if constraints are defined, the method must satisfy them.method A method may be illustrated several ways, including: – in interaction diagrams, by the details and sequence of messages – in class diagrams, with a UML note symbol stereotyped with «method» Show Methods

Feb 11, When we use a UML note to show a method, we are mixing static and dynamic views in the same diagram. The method body (which defines dynamic behavior) adds a dynamic element to the static class diagram. This style is good for book or document diagrams and tool-generated output, but perhaps too fussy or stylized for sketching or tool input. Tools may provide a popup window to simply enter the code for a method. Show Methods Register... endSale() enterItem(id,qty) makeNewSale() makePayment(cashTendered) «method» //pseudo-code or a specific language is OK public void enterItem(id,qty) { ProductDescription desc=catalog.getProductDescription(id); sale.makeLineItem(desc,qty); }

Feb 11, The create message in an interaction diagram is normally interpreted as the invocation of the new operator and a constructor call in languages such as Java and C#. In a DCD this create message will usually be mapped to a constructor definition, using the rules of the language - such as the constructor name equal to the class name (Java, C#, C++, …). Operation Issues- The Create Operation

Feb 11, Accessing operations retrieve or set attributes, such as getPrice and setPrice. These operations are often excluded (or filtered) from the class diagram because of the high noise- to-value ratio they generate; for n attributes, there may be 2n uninteresting getter and setter operations. Most UML tools support filtering their display, and it's especially common to ignore them while wall sketching. Operation Issues- Operations to Access Attributes

Feb 11, A UML keyword is a textual adornment to categorize a model element. – For example, the keyword to categorize that a classifier box is an interface is «interface». – The «actor» keyword was used in use case diagram to replace the human stick-figure actor icon with a class box to model computer-system or robotic actors. Guideline: When sketching UML-when we want speed, ease, and creative flow-modelers often simplify keywords to something like ' ' or ' '. Keywords

Feb 11, Most keywords are shown in guillemet (« ») but some are shown in curly braces, such as {abstract}, which is a constraint containing the abstract keyword. In general, when a UML element says it can have a "property string“ - such as a UML operation and UML association end have-some of the property string terms will be keywords (and some may be user defined terms) used in the curly brace format. Keywords

Feb 11, Keywords

Feb 11, In the UML, a property is "a named value denoting a characteristic of an element. Some properties are predefined in the UML, such as visibility - a property of an operation. Others can be user-defined. Properties of elements may be presented in many ways, but a textual approach is to use the UML property string – {name1=value1, name2=value2} format, such as {abstract, visibility=public}. – Some properties are shown without a value, such as {abstract}; this usually implies a boolean property, shorthand for {abstract=true}. UML Properties and Property String

Feb 11, Generalization in the UML is shown with a solid line and fat triangular arrow from the subclass to superclass. (See Figure 16.1) Generalization What does it mean? Is this the same as OO programming language (OOPL) inheritance? It depends…inheritance In a domain model conceptual-perspective class diagram, the answer is no. Rather, it implies the superclass is a superset and the subclass is a subset. Generalization, Abstract Classes, Abstract Operations

Feb 11, On the other hand, in a DCD software-perspective class diagram, it implies OOPL inheritance from the superclass to subclass. Abstract classes and operations can be shown either with an {abstract} tag (useful when sketching UML) or by italicizing the name (easy to support in a UML tool). The opposite case, final classes and operations that can't be overridden in subclasses, are shown with the {leaf} tag. Generalization, Abstract Classes, Abstract Operations

Feb 11, Dependency lines may be used on any diagram, but are especially common on class and package diagrams. The UML includes a general dependency relationship that indicates that a client element (of any kind, including classes, packages, use cases, and so on) has knowledge of another supplier element and that a change in the supplier could affect the client. Dependency

Feb 11, Dependency is illustrated with a dashed arrow line from the client to supplier. Dependency can be viewed as another version of coupling, a traditional term in software development when an element is coupled to or depends on another. coupling There are many kinds of dependency; here are some common types in terms of objects and class diagrams : Dependency

Feb 11, – having an attribute of the supplier type – sending a message to a supplier; the visibility to the supplier could be: an attribute, a parameter variable, a local variable, a global variable, or class visibility (invoking static or class methods) – receiving a parameter of the supplier type – the supplier is a superclass or interface Dependency

Feb 11, All of these could be shown with a dependency line in the UML, but some of these types already have special lines that suggest the dependency. – For example, there's a special UML line to show the super class, one to show implementation of an interface, and one for attributes (the attribute-as-association line). So, for those cases, it is not useful to use the dependency line. – For example, a Sale has some kind of dependency on SalesLineItems by virtue of the association line. Since there's already an association line between these two elements, adding a second dashed arrow dependency line is redundant. Dependency

Feb 11, when to show a dependency? Guideline: In class diagrams use the dependency line to depict global, parameter variable, local variable, and static-method (when a call is made to a static method of another class) dependency between objects. For example, the following Java code shows an updatePriceFor method in the Sale class: Dependency

Feb 11, public class Sale { public void updatePriceFor( ProductDescription description ) { Money basePrice = description.getPrice(); //… } // … } The updatePriceFor method receives a ProductDescription parameter object and then sends it a getPrice message. Therefore, the Sale object has parameter visibility to the ProductDescription, and message-sending coupling, and thus a dependency on the ProductDescription. If the latter class changed, the Sale class could be affected. This dependency can be shown in a class diagram Dependency

Feb 11, Dependency

Feb 11, Another example: The following Java code shows a doX method in the Foo class: public class Foo { public void doX() { System.runFinalization(); //… } // … } The doX method invokes a static method on the System class. Therefore, the Foo object has a static-method dependency on the System class. This dependency can be shown in a class diagram Dependency

Feb 11, To show the type of dependency, or to help a tool with code generation, the dependency line can be labeled with keywords or stereotypes, for example: Dependency

Feb 11, Dependency «call» Window a dependency on calling on operations of the operations of aClock getTime()... «create» A a dependency that A objects create B objects B...

Feb 11, The UML provides several ways to show – interface implementation, interface – providing an interface to clients, and – interface dependency (a required interface). In the UML, interface implementation is formally called interface realization Interface

Feb 11, Interface

Feb 11, Constraints may be used on most UML diagrams, but are especially common on class diagrams. A UML constraint is a restriction or condition on a UML element. It is visualized in text between braces; for example: { size >= 0 }. The text may be natural language or anything else.constraint Constraints

Feb 11, A qualified association has a qualifier that is used to select an object (or objects) from a larger set of related objects, based upon the qualifier key.qualified association Informally, in a software perspective, it suggests looking things up by a key, such as objects in a HashMap. For example, if a ProductCatalog contains many ProductDescriptions, and each one can be selected by an itemID, Qualified Association

Feb 11, An association class allows you treat an association itself as a class, and model it with attributes, operations, and other features. For example, if a Company employs many Persons, modeled with an Employs association, you can model the association itself as the Employment class, with attributes such as startDate. In the UML, it is illustrated with a dashed line from the association to the association class. Association Class

Feb 11, Singleton Class

Feb 11, In addition to common predefined compartments class compartments such as name, attributes, and operations, user-defined compartments can be added to a class box. User-Defined Compartments

Feb 11, When we draw interaction diagrams, a set of classes and their methods emerge from the creative design process of dynamic object modeling. – For example, if we started with the (trivial for explanation) makePayment sequence diagram, we see that a Register and Sale class definition in a class diagram can be obviously derived. the Relationship Between Interaction and Class Diagrams

Feb 11, Thus, from interaction diagrams the definitions of class diagrams can be generated. This suggests a linear ordering of drawing interaction diagrams before class diagrams, but in practice, especially when following the agile modeling practice of models in parallel, these complementary dynamic and static views are drawn concurrently. the Relationship Between Interaction and Class Diagrams