LEHIGH CSE 432 - Visibility (9 pages)

Previewing pages 1, 2, 3 of 9 page document View the full content.
View Full Document

Visibility



Previewing pages 1, 2, 3 of actual document.

View the full content.
View Full Document
View Full Document

Visibility

40 views


Pages:
9
School:
Lehigh University
Course:
Cse 432 - Object Oriented Software Engr

Unformatted text preview:

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 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 class Register private ProductCatalog catalog enterItem itemID quantity Fig 19 1 Register ProductCatalog desc getProductDesc itemID public void enterItem itemID qty desc catalog getProductDesc itemID Four Kinds of Visibility OO programming languages may provide four levels of scope for names Attribute visibility Parameter visibility Local visibility Global visibility Attribute Visibility Fig 19 2 Parameter Visibility Fig 19 3 Why is transforming parameters to attribute visibilit common in OO design Global Visibility Object B has global scope relative to A Relatively permanent visibility Least common visibility in OO design Ways to achieve global visibility Assign an instance to a global variable 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 Why not use a global variable class Singleton public static Singleton getInstance accessor protected Why are the following protected Singleton Singleton const Singleton Singleton operator const Singleton private static Singleton instance unique 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



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Visibility and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Visibility and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?