NJIT Designing for Visibility Chapter 19 Applying UML and Patterns Craig Larman.

Slides:



Advertisements
Similar presentations
PHP functions What are Functions? A function structure:
Advertisements

Visibility Larman, Chapter 19 (with ideas from George Blank of NJIT) CSE432 Object Oriented Software Engineering.
Stereotypes Stereotypes provide the capability to create a new kind of modeling element. –They can be used to classify or mark modeling elements. –A type.
Sucha Smanchat  Steps in OOAD using UML  Use Case Diagram  Sequence Diagram / Communication Diagram  Class Diagram  State.
Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions.
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Road Map Introduction to object oriented programming. Classes
UML – Class Diagrams.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
November Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object.
Abstract Data Types and Encapsulation Concepts
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation (Adapted) Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra,
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
Object-Oriented Analysis and Design
Comparison of OO Programming Languages © Jason Voegele, 2003.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
Systems Analysis and Design in a Changing World, Fifth Edition
SE-1010 Dr. Mark L. Hornick 1 Introduction to Object-Oriented Programming (OOP) Part 1.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
Chapter 16 Applying UML and Patterns Craig Larman
© 2005 Prentice Hall9-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
CPS120: Introduction to Computer Science Functions.
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.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
Part VII: Design Continuous
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
Relationships Relationships between objects and between classes.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
12 Chapter 12: Advanced Topics in Object-Oriented Design Systems Analysis and Design in a Changing World, 3 rd Edition.
1 Chapter 5: Defining Classes. 2 Basics of Classes An object is a member of a class type What is a class? Fields & Methods Types of variables: –Instance:
Object-Oriented Analysis and Design Week 11, 2009.
Class diagrams Terézia Mézešová.
Chapter 16: UML Class Diagrams
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
A Survey of Object-Oriented Concept Oscar Nierstrasz.
Use-Case Model: Adding Detail with Operation Contracts.
11 Systems Analysis and Design in a Changing World, Fifth Edition.
Design Model: Determining Visibility CH-18. Objectives Identify four kinds of visibility. Design to establish visibility. Illustrate kinds of visibility.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Paul Ammann & Jeff Offutt
Object-Oriented Analysis and Design
GRASP: Visibility and Design
GoF Patterns (GoF) popo.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
The Object Oriented Approach to Design
Interactions.
Requirements To Design In This Iteration
Chapter 10: Visibility Chapter 18 in Applying UML and Patterns Book.
Chapter 20 Applying UML and Patterns Craig Larman
Class Diagrams.
UNIT I OBJECT ORIENTED PROGRAMMING FUNDAMENTALS
CS 350 – Software Design Singleton – Chapter 21
Chapter 16 UML Class Diagrams
Object Oriented System Design Class Diagrams
Creating and Using Classes
Presentation transcript:

NJIT Designing for Visibility Chapter 19 Applying UML and Patterns Craig Larman

Objectives Identify four kinds of visibility Design to establish visibility Illustrate kinds of visibility in the UML notation

Introduction Q. What is visibility? A. Visibility is the ability of one object to see or have reference to another.

Visibility Between Objects Q. When is visibility necessary? A. To send a message from one object to another, the receiver object must be visible to the sender, so the sender has to have a pointer or reference to the receiver.

Visibility Between Objects Example: Q. If A sends messages to B, which must be visible to which? A. B is visible to A means A can send a message to B. Some say that "B is an acquaintance of A".

Visibility Between Objects

Visibility Visibility is related to the scope: Is one resource (such as an instance) within the scope of another? The motivation to consider visibility: For an object A to send a message to an object B, B must be visible to A.

Four Kinds of Visibility How visibility can be achieved from object A to object B: Attribute visibility - B is an attribute of A Parameter visibility - B is a parameter of a method of A Local visibility - B is a local object in a method of A Global visibility - B is in some way globally visible

Attribute Visibility Attribute visibility from A to B exists when B is an attribute of A Relatively permanent visibility because it persists as long as A and B exist Common form of visibility public class Register {… private ProductCatalog Catalog; … }

Attribute Visibility

Parameter Visibility Parameter visibility from A to B exists when B is passed as a parameter to a method of A. Relatively temporary visibility because it persists only within the scope of the method The 2 nd most common form of visibility in the OO systems

Parameter Visibility

Parameter to attribute Visibility It is common to transform parameter visibility into attribute visibility.

Local Visibility Local visibility from A to B exists when B is declared as a local object within a method of A. Relatively temporary visibility since it persists only within the scope of the method.

Local Visibility There are two common means by which local visibility is achieved: Create a new local instance and assign it to a local variable. Assign the returning object from a method invocation to a local variable. A variation of this method does not explicitly declare a variable, but one implicitly exists as the result of a returning object from a method invocation Ex: anObject.getAnotherObject.doSomething();

Global Visibility Global visibility from A to B exists when B is global to A. Relatively permanent visibility since it persists as long as A and B exist. The least common form of visibility in OO Systems.

Global Visibility Ways to achieve global visibility: Assign an instance to a global variable. Use the Singleton pattern

Singleton Pattern (Gang of Four) Problem: Exactly one instance of a class is needed. Objects need a single point of access. Solution: Define a class method that returns the singleton object, instantiating it if it does not exist. Example: A print queue—many programs must access one queue

Illustrating Visibility in the UML

Visibility in the UML Public: Any outside classifier with visibility to the given classifier can use the feature; specified by pre- pending the symbol “+” Protected: Any descendant of the classifier can use the feature; specified by pre-pending the symbol “#” Private: Only the classifier itself can use the feature; specified by pre-pending the symbol “-”

Terms: Classifier A classifier is a mechanism that describes structural and behavioral features. Modeling elements that can have instances are called classifiers. Classifiers include classes, interfaces, datatypes, signals, components, nodes, use cases, and subsystems. A classifier has structural feature (in the form of attributes), as well as behavioral features (in the form of operations).

Terms: Feature A feature is a property, such as operations or attributes that is encapsulated within entity such as an interface, a class, or a datatype.

Questions & Answers Q. Which would you use if you wanted a relatively permanent connection? A. attribute, or global Q. Which would you use if you didn't want a permanent connection? A.parameter, or local Q. How would you create a local visibility? A. create a new instance - use result of a method call

Questions & Answers Q.how would you achieve a global visibility? A.use a global variable in C++, static (or class) variable (in C++ or Java) - use the Singleton pattern (a static method that returns the object)