Visibility Larman, Chapter 19 (with ideas from George Blank of NJIT) CSE432 Object Oriented Software Engineering.

Slides:



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

Chapter 1 Object Oriented Analysis and Design. UML, Patterns, and Object-Oriented Analysis and Design  The essential skills for the creation of well-designed,
© Keith Vander Linden, Dilbert © United Feature Syndicate, Inc.
Fall 2009AXS-3913 Ron McFadyen Visibility Visibility: the ability of one object to see or have a reference to another object. e.g. When a register object.
Fall 2009ACS-3913 Ron McFadyen1 Design Class Diagrams n Class diagram with – classes – associations – attributes – methods – navigability – interfaces,
Copyright W. Howden1 Lecture 7: Functional and OO Design Descriptions.
Road Map Introduction to object oriented programming. Classes
Chapter 16. Fig Fig Note: If Sale references nothing then the only thing it is associated with is what references it Note: association name.
Fundamentals of Software Development 1Slide 1 Gang of Four The beginnings… The original “patterns” idea was from architecture – there are repeatable patterns.
Patterns Lecture 2. Singleton Ensure a class only has one instance, and provide a global point of access to it.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Eva TrosborgSlide no.: 1Elaboration Iteration 2 Object Oriented design and more patterns Fall 2005 UML Tools and UML as Blueprint (chapter 22, p 397)
March R McFadyen1 GoF (Gang of Four): Gamma, Johnson, Helm & Vlissides Book: Design Patterns: Elements of Reusable Object-Oriented Software.
Fall 2009ACS-3913 R McFadyen1 Singleton Problem: Exactly one instance of a certain object is required (this object is called a singleton). We must ensure.
1 Scenario: Audio Clip Imagine that your application played an audio clip Based on user action, a different audio clip may begin playing You want only.
November Ron McFadyen1 Design Class Diagrams n Class diagram with – classes – associations – attributes – methods – navigability – interfaces,
NJIT Designing for Visibility Chapter 19 Applying UML and Patterns Craig Larman.
Design Patterns Ref : Chapter 15 Bennett et al. useful groups of collaborating classes that provide a solution to commonly occuring problems. provide.
Chapter 26 Applying Gang of Four Design Patterns 1CS6359 Fall 2012 John Cole.
Object Oriented Software Development
Design Dan Fleck CS 421 George Mason University. What is the design phase? Analysis phase describes what the system should do Analysis has provided a.
CSSE 374: Introduction to Gang of Four Design Patterns
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Factory, Singleton & Strategy All References and Material From: Applying UML and Patterns, 3 rd ed, chpt 26 & 13 BTS530: Major Project Planning and Design.
BTS430 Systems Analysis and Design using UML Design Patterns.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
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.
Chapter 16 Applying UML and Patterns Craig Larman
© 2005 Prentice Hall9-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
CSE 432: Design Patterns Introduction What’s a Pattern? What’s an Idiom? According to Alexander, a pattern: –Describes a recurring problem –Describes the.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
Singleton and Basic UML CS340100, NTHU Yoshi. What is UML Unified Modeling Language A standardized general-purpose modeling language in the field of software.
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
02/14/2005 Introduction to Programming with Java, for Beginners Midterm 1 Review.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Design Patterns Introduction
Object-Oriented Analysis and Design Week 11, 2009.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
Chapter 11 An introduction to object-oriented design.
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.
Re-Intro to Object Oriented Programming
GRASP: Visibility and Design
Java Software Solutions
GoF Patterns (GoF) popo.
MPCS – Advanced java Programming
Creating Your OwnClasses
Types of Programming Languages
HIGHLEVEL REVIEW Chapter 9 Objects and Classes
Corresponds with Chapter 7
Chapter 10: Visibility Chapter 18 in Applying UML and Patterns Book.
Chapter 20 Applying UML and Patterns Craig Larman
Object Oriented Design Patterns - Creational Patterns
Chapter 22 Object-Oriented Design
What is Singleton Category: Creational pattern
Singleton Pattern Pattern Name: Singleton Pattern Context
Singleton design pattern
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
CS 350 – Software Design Singleton – Chapter 21
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Chapter 16 UML Class Diagrams
Object Oriented System Design Class Diagrams
Java Software Solutions
Presentation transcript:

Visibility Larman, Chapter 19 (with ideas from George Blank of NJIT) CSE432 Object Oriented Software Engineering

What is visibility? Visibility is the ability of one object to “see” or have reference to another Visibility is the ability of one object to “see” or have reference to another To send a message from one object to another, the receiver object must be “visible” to the sender, via a reference To send a message from one object to another, the receiver object must be “visible” to the sender, via a reference

What does the getProductDesc message imply about object visibility? Fig. 19.1

Four Kinds of Visibility OO programming languages may provide four levels of scope for names: Attribute visibility Attribute visibility Parameter visibility Parameter visibility Local visibility Local visibility Global visibility Global visibility

Attribute Visibility Fig. 19.2

Parameter Visibility Fig Why is transforming parameters to attribute visibility common in OO design? Why is transforming parameters to attribute visibility common in OO design?

Global Visibility Object B has global scope relative to A Object B has global scope relative to A Relatively permanent visibility Relatively permanent visibility Least common visibility in OO design Least common visibility in OO design Ways to achieve global visibility: Ways to achieve global visibility: Assign an instance to a global variable. Assign an instance to a global variable. Use the Singleton pattern Use the Singleton pattern

Singleton design pattern Gamma, Helm, Johnson, and Vlissides (aka Gang of Four) Ensure that a class has only one instance and provide a global point of access to it Ensure that a class has only one instance and provide a global point of access to it Why not use a global variable? Why not use a global variable? class Singleton { public: static Singleton* getInstance(); //accessor static Singleton* getInstance(); //accessor protected: //Why are the following protected? protected: //Why are the following protected? Singleton(); Singleton(); Singleton(const Singleton&); Singleton(const Singleton&); Singleton& operator= (const Singleton&); Singleton& operator= (const Singleton&); private: static Singleton* instance; //unique private: static Singleton* instance; //unique }; }; Singleton *p2 = p1->getInstance(); Singleton *p2 = p1->getInstance();

Questions for discussion Q. Which would you use if you wanted a relatively permanent connection between sender & receiver objects? 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 achieve global visibility? A.use a global variable in C++, static (or class) variable (in C++ or Java) or the Singleton pattern (a static method that returns the object)