Object-Oriented Programming Encapsulation Control/Visibility (VRH 7. 3

Slides:



Advertisements
Similar presentations
Introduction to classes Sangeetha Parthasarathy 06/11/2001.
Advertisements

Based on Java Software Development, 5th Ed. By Lewis &Loftus
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
C. Varela; Adapted from S. Haridi and P. Van Roy1 Declarative Programming Techniques Lazy Execution (VRH 4.5) Carlos Varela RPI Adapted with permission.
C++ Classes & Data Abstraction
CSCI 1100/1202 April 3, Testing A program should be executed multiple times with various input in an attempt to find errors Debugging is the process.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Copyright 2002 by S. Haridi and P. Van Roy1 Object-Oriented Programming Seif Haridi Peter Van Roy.
Object-Oriented PHP (1)
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Single assignment store Kernel language syntax Carlos Varela.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Data Abstraction and State Abstract Data Types (3.7) State/Data Abstraction(6.1, 6.3, 6.4.1,
C. Varela; Adapted from S. Haridi and P. Van Roy1 Object-Oriented Programming Objects, Classes and Inheritance (VRH 7.1-2) Polymorphism (VRH 6.4.3) Carlos.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Data Abstraction, State, and Objects Abstract Data Types (VRH 3.7) State / Data Abstraction(VRH.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Kernel language semantics Carlos Varela RPI Adapted with permission.
C. Varela; Adapted from S. Haridi and P. Van Roy1 Object-Oriented Programming Active Objects (VRH 7.8) Carlos Varela RPI Adapted with permission from:
C. Varela; Adapted from S. Haridi and P. Van Roy1 Object-Oriented Programming Objects, Classes and Inheritance (VRH 7.1-4) Polymorphism (VRH 6.4.3) Carlos.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
16/22/2015 2:54 PM6/22/2015 2:54 PM6/22/2015 2:54 PMObject-Oriented Development Concept originated with simulating objects and their interactions. Adapted.
C. Varela; Adapted from S. Haridi and P. Van Roy1 Object-Oriented Programming Inheritance (VRH 7.3-4) Object System Implementation/Java(VRH 7.6-7) Carlos.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Memory management, Exceptions, From kernel to practical language.
Week 5 Recap CSE 115 Spring Composition Informally called “has a” Represented in UML with a diamond- headed arc In code: Declare an instance variable.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Programming Techniques Non-declarative needs (VRH 3.8) Program design in the.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Classes Mark Hennessy Dept. Computer Science NUI Maynooth C++ Workshop 18 th – 22 nd Spetember 2006.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Copyright S. Haridi & P. Van Roy1 Object-Oriented Programming Seif Haridi Peter Van Roy.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Memory management (CTM 2.5) Carlos Varela RPI April 6, 2015.
Introduction To Classes Chapter Procedural And Object Oriented Programming Procedural programming focuses on the process/actions that occur in a.
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.
Inheritance Chapter 10 Programs built from objects/instances of classes An O.O. approach – build on earlier work. Use classes in library and ones you have.
C. Varela; Adapted w. permission from S. Haridi and P. Van Roy1 Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections ,
C# G 1 CSC 298 Object Oriented Programming Part 2.
CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
C++ Objects and Scope. Important Definitions  Class  Access and Visibility  Encapsulation  Unified Modeling Language (UML)  Constructor  Destructor.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Higher-Order Programming: Iterative computation (CTM Section 3
Introduction to Object-oriented Programming
Object-Oriented Programming
Object-Oriented Design
Functional Programming: Lists, Pattern Matching, Recursive Programming (CTM Sections , 3.2, , 4.7.2) Carlos Varela RPI September 12,
Higher-Order Programming: Iterative computation (CTM Section 3
Carlos Varela RPI September 22, 2017 Adapted with permission from:
Table of Contents Class Objects.
State, Object-Oriented Programming Explicit State, Polymorphism (CTM 6
Road Map Introduction to object oriented programming. Classes
Anatomy of a Class & Method
Declarative Computation Model Kernel language semantics (Non-)Suspendable statements (VRH ) Carlos Varela RPI October 11, 2007 Adapted with.
Corresponds with Chapter 7
More Object-Oriented Programming
Higher-Order Programming: Closures, procedural abstraction, genericity, instantiation, embedding. Control abstractions: iterate, map, reduce, fold, filter.
Java Programming Course
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Introduction to Programming Concepts (VRH )
Declarative Computation Model Single assignment store (VRH 2
Introduction to Programming Concepts
Object-Oriented PHP (1)
State, Object-Oriented Programming Explicit State, Polymorphism (CTM 6
Presentation transcript:

Object-Oriented Programming Encapsulation Control/Visibility (VRH 7. 3 Carlos Varela RPI Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL April 16, 2015 C. Varela; Adapted from S. Haridi and P. Van Roy

Controlling visibility Visibility is the control given to the user to limit access to members of a class (attributes, methods and properties) Each member is defined with a scope (part of program text that the member can be accessed by name) Programming languages use words like public, private and protected to define visibility Unfortunately different languages use these keywords to define different scopes C. Varela; Adapted from S. Haridi and P. Van Roy

Public and private scopes in ADTs A private member is one which is only visible in the object instance (it is used for implementing the ADT) The object instance can see all the private members in its class and its super classes A public member is visible anywhere in the program It is part of the interface of the ADT In Oz (and Smalltalk) attributes are private and methods are public (the default rule) In Java and C++ private has another meaning C. Varela; Adapted from S. Haridi and P. Van Roy

C. Varela; Adapted from S. Haridi and P. Van Roy The meaning of Private C Class Hierarchy SubC SubSubC I1 I2 I3 I4 Instances C. Varela; Adapted from S. Haridi and P. Van Roy

C. Varela; Adapted from S. Haridi and P. Van Roy The meaning of Private C Class Hierarchy According to Smalltalk and Oz SubC All private members in this region are visible to I3 SubSubC I1 I2 I3 I4 Instances C. Varela; Adapted from S. Haridi and P. Van Roy

C. Varela; Adapted from S. Haridi and P. Van Roy The meaning of Private C Class Hierarchy According to C++ and Java All private members in this region are visible to I3 SubC SubSubC I1 I2 I3 I4 Instances C. Varela; Adapted from S. Haridi and P. Van Roy

Public and private scopes in ADTs In Oz (and Smalltalk) attributes are private and methods are public It is possible in Oz to make a method private within a class Using a variable identifier as a method head will make the method local to the class The variable is automatically bound to a unique name class C meth A(...) ... end .... end C. Varela; Adapted from S. Haridi and P. Van Roy

Public and private scopes in ADTs In Oz (and Smalltalk) attributes are private and methods are public It is possible in Oz to make a method private within a class Using a variable identifier as a method head will make the method local to the class The variable is automatically bound to a unique name ! is an escape character, !A means escape the class scope class C meth A(...) ... end .... end local A = {NewName} in class C meth !A(...) ... end .... end C. Varela; Adapted from S. Haridi and P. Van Roy