Object-Oriented Programming (OOP) Lecture No. 2. Information Hiding ► Information is stored within the object ► It is hidden from the outside world ►

Slides:



Advertisements
Similar presentations
F27SB2 Software Development 2 Lecture 1: Introduction.
Advertisements

COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
GUI Testing. High level System Testing Test only those scenarios and outputs that are observable by the user Event-driven Interactive Two parts to test.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
Abstract Data Types (ADTs) An ADT consists of: –a set of values, and –a set of operations on those values. Example: rational numbers –some values: 15/7,
Introduction To System Analysis and Design
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Object-oriented Programming Concepts
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Object-Oriented Analysis and Design
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
BACS 287 Basics of Object-Oriented Programming 1.
The chapter will address the following questions:
Computer Organization
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Object Oriented Programming with JAVA Arash N. Kia AlZahra University Definitions – Part 1.
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
What Is Object-Orientation?
Introduction To System Analysis and Design
Object-Oriented Programming (OOP) CSC-2071 (3+1=4 Credits) Lecture No. 1 MBY.
Object Oriented Programming Principles Lecturer: Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Session-3.
Chapter 17 Creating a Database.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
Movement-Machines-Cars Question: How do cars work?
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
CSC241 Object-Oriented Programming (OOP) Lecture No. 1.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Object-Oriented Programming •Object-Oriented Programming (OOP) allows you to create your program based upon modeling objects.  Your program’s properties.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Salman Marvasti Sharif University of Technology Winter 2015.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Object-Oriented Programming (OOP) Lecture No. 3 Downloaded From:
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
Algorithms CS280 – 10/20/05. Announcement  Part 1 of project 2 due.  Read chapters 10, 7 for this unit  Tuesday we will also be in the classroom We.
Programming Paradigms Different paradigms Procedural paradigm, e.g. Pascal Basic Functional paradigm, e.g. Lisp Declarative paradigm, e.g. Prolog Object-Oriented.
STEP MOTOR Yisheng Zhang. Overview What is a step motor? How to control it? Why to use it? Where to use it? How to select it? Where to get it?
Lecture 7 Page 1 CS 111 Online Process Communications and Concurrency CS 111 On-Line MS Program Operating Systems Peter Reiher.
Java How to Program, 9/e Presented by: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Chapter 2: Advanced programming concepts Part 3: The user interface Lecture 5 1.
Object-Oriented Paradigm (OOP) Course Code: SE 101 Lecture No. 1.
Object Oriented Paradigm OOP’s. Problems with Structured Programming As programs grow ever larger and more complex, even the structured programming approach.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Programming Logic and Design Seventh Edition
The Object-Oriented Thought Process Chapter 1
Object-Oriented Programming
Object-Oriented Programming (OOP) Lecture No. 2
Encapsulation & Visibility Modifiers
Subprograms and Programmer Defined Data Type
Object-Oriented Programming
Object oriented vs procedural programming
Object-Oriented Programming
Object-Oriented Programming
Object-Oriented Programming (OOP) Lecture No. 5
Object-Oriented Programming
Object-Oriented Programming
Presentation transcript:

Object-Oriented Programming (OOP) Lecture No. 2

Information Hiding ► Information is stored within the object ► It is hidden from the outside world ► It can only be manipulated by the object itself

Example – Information Hiding ► Ali’s name is stored within his brain ► We can’t access his name directly ► Rather we can ask him to tell his name

Example – Information Hiding ► A phone stores several phone numbers ► We can’t read the numbers directly from the SIM card ► Rather phone-set reads this information for us

Information Hiding Advantages ► Simplifies the model by hiding implementation details ► It is a barrier against change propagation

Encapsulation ► Data and behaviour are tightly coupled inside an object ► Both the information structure and implementation details of its operations are hidden from the outer world

Example – Encapsulation ► Ali stores his personal information and knows how to translate it to the desired language ► We don’t know  How the data is stored  How Ali translates this information

Example – Encapsulation ► A Phone stores phone numbers in digital format and knows how to convert it into human-readable characters ► We don’t know  How the data is stored  How it is converted to human-readable characters

Encapsulation – Advantages ► Simplicity and clarity ► Low complexity ► Better understanding

Object has an Interface ► An object encapsulates data and behaviour ► So how objects interact with each other? ► Each object provides an interface (operations) ► Other objects communicate through this interface

Example – Interface of a Car ► Steer Wheels ► Accelerate ► Change Gear ► Apply Brakes ► Turn Lights On/Off

Example – Interface of a Phone ► Input Number ► Place Call ► Disconnect Call ► Add number to address book ► Remove number ► Update number

Implementation ► Provides services offered by the object interface ► This includes  Data structures to hold object state  Functionality that provides required services

Example – Implementation of Gear Box ► Data Structure  Mechanical structure of gear box ► Functionality  Mechanism to change gear

Example – Implementation of Address Book in a Phone ► Data Structure  SIM card ► Functionality  Read/write circuitry

Separation of Interface & Implementation ► Means change in implementation does not effect object interface ► This is achieved via principles of information hiding and encapsulation

Example – Separation of Interface & Implementation ► A driver can drive a car independent of engine type (petrol, diesel) ► Because interface does not change with the implementation

Example – Separation of Interface & Implementation ► A driver can apply brakes independent of brakes type (simple, disk) ► Again, reason is the same interface

Advantages of Separation ► Users need not to worry about a change until the interface is same ► Low Complexity ► Direct access to information structure of an object can produce errors

Messages ► Objects communicate through messages ► They send messages (stimuli) by invoking appropriate operations on the target object ► The number and kind of messages that can be sent to an object depends upon its interface

Examples – Messages ► A Person sends message (stimulus) “stop” to a Car by applying brakes ► A Person sends message “place call” to a Phone by pressing appropriate button