Abstraction ADTs, Information Hiding and Encapsulation.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
4. Object-Oriented Programming Procedural programming Structs and objects Object-oriented programming Concepts and terminology Related keywords.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Basic OO Technology Technology determines the effectiveness of the approach.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
1 CIS601: Object-Oriented Programming in C++ Note: CIS 601 notes were originally developed by H. Zhu for NJIT DL Program. The notes were subsequently revised.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Object-oriented Programming Concepts
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C++ fundamentals.
 By Wayne Cheng.  Introduction  Five Tenets  Terminology  The foundation of C++: Classes.
OBJECT ORIENTED PROGRAMMING
BACS 287 Basics of Object-Oriented Programming 1.
Introduction to Object-oriented programming and software development Lecture 1.
© 2008 Dr. Paul Walcott – The University of the West Indies: Cave Hill CampusDr. Paul Walcott COMP6325 Advanced Web Technologies Dr. Paul Walcott The University.
11 1 Object oriented DB (not in book) Database Systems: Design, Implementation, & Management, 6 th Edition, Rob & Coronel Learning objectives: What.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
CSCI-383 Object-Oriented Programming & Design Lecture 4.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.
An Object-Oriented Approach to Programming Logic and Design
Sadegh Aliakbary Sharif University of Technology Fall 2011.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Abstraction CMPS Abstraction Abstraction mechanisms are techniques to deal with creating, understanding and managing complex systems Abstraction.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Learners Support Publications Object Oriented Programming.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
CSC 131 Fall 2006 Lecture # 6 Object-Oriented Concepts.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
Salman Marvasti Sharif University of Technology Winter 2015.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
OBJECT ORIENTED PROGRAMMING. Design principles for organizing code into user-defined types Principles include: Encapsulation Inheritance Polymorphism.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
OOP Basics Classes & Methods (c) IDMS/SQL News
Programming Paradigms(Model) Two Paradigms: – Procedural Programming Paradigm – Object Oriented Paradigm Objective of OO approach is to eliminate some.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
1 C++ Classes & Object Oriented Programming Overview & Terminology.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
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 paradigms
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
JAVA By Waqas.
ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:
About the Presentations
Object Oriented Concepts -I
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Object Oriented Analysis and Design
Object-Oriented Programming
More Object-Oriented Programming
CIS601: Object-Oriented Programming in C++
ITEC 3220A Using and Designing Database Systems
Introduction to Object-Oriented Programming
Object-Oriented Programming
Object-Oriented Programming
Programming Languages and Paradigms
What Is Good Software(Program)?
Presentation transcript:

Abstraction ADTs, Information Hiding and Encapsulation

ADT ADT = Abstract Data Type –A theoretical concept –A set of (homogeneous) objects together with a set of operations on those objects –NO mention of how the operations are implemented –NO rules tell which operations are required A design decision

Two Faces of an ADT From the outside, the user sees only a collection of operations that together define the behavior of the abstraction On the other side, the programmer defining the abstraction sees the data variables that are used to maintain the state

Stack ADT The user sees only the description of the legal operations -- push and pop The implementer knows the concrete data structure used to implement the abstraction The concrete details are encapsulated within a more abstract framework

ADTs (cont’d) To build an ADT, we must 1.Export the type definition 2.Make available a set of operations to manipulate instances of this type 3.Protect the data associated with the type so they can be operated on only by provided operations 4.Make multiple instances of the type

Abstraction A mechanism to control complexity –Complexity due to interconnections between software components. I.e. the dependence of one portion of code on another section of code The ability to encapsulate and isolate design and execution information Using data abstraction is a methodology wherein information is consciously hidden in a small part of a program

Procedures First Abstraction Method –Allowed repeated tasks to be collected in one place and be reused –Gave possibility for information hiding One programmer writes procedure(s) Other programmers just need to know interface, not implementation

Characteristics Behaviors Function 2 Function 1 Function N In a procedural application, the characteristics (data) and behaviors (functions) may be in the same file

Characteristics Or may be in different files. There may be more than one set of data which use the same functions. Behaviors

Procedural Stack Example main ( ) { STACK s1; STACK s2; push (s1, 7); push (s1, 10); push (s2, 5); push (s2, pop(s1));. ………. } void push (STACK s, int i) { // code for push } int pop (STACK s) { // code for pop }

What’s the Problem? The data (STACK variables s1 and s2) are changeable by any line of code in main( ) The data is “public”

Modules A collection of procedures and related data (a.C file) divided into two parts –Public part accessible outside the module –Private part accessible only within the module

Modules (cont’d) Popularized by David Parnas –“[A module] must provide the intended user with all the information needed to use the module correctly, and with nothing more.” –“[A module] must provide the implementer with all the information needed to complete the module, and nothing more”. Like the military “need to know” philosophy

Modules (cont’d) Solve some (not all) software development problems Ex: Stack module –Stack data private –Stack routines public

main ( ) { …. } Private Characteristics Public Behaviors Main.C Stack.C

Modular Stack Example main ( ) { push (7); push (12): push (15); int x = pop ( ); ………. } static STACK s; void push (int i) { // code for push } int pop ( void ) { // code for pop }

What’s the Problem? Question: How do you use more than one stack at a time? Answer: You don’t

ADTs with OOP OOP allows us to instantiate multiple instances of each object. Each gets its own set of characteristics. Conceptually, each gets its own set of behaviors This was what procedures and modules couldn’t give us

Objects The characteristics and behaviors are encapsulated in a single entity (an object). That entity decides which characteristics and which behaviors are publicly available and which remain private.

Encapsulation Restricting the effects of change by putting a “wall of code” around the data All access to the data is handle by procedures (functions, behaviors) that were put there to mediate access to the data

An OOP Application Object Oriented Application Public Behaviors private Characteristics An Object

Message Passing OOP extends the concept of ADT by adding the concept of message passing. A program requests that an object perform a certain operation. Objects can also request that other objects perform operations

A Change of Emphasis Do you call the push routine with a stack and a data value OR Do you ask a stack object to push a value onto itself

Inheritance Allows different data types to share the same code –Reduced code size –Increased functionality

VEHICLE Land Vehicle Car Bicycle Train Boat Submarine Plane Zeppelin Water Vehicle Commercial Military Private Air Vehicle

Procedural “Polymorphism” Procedural Application Characteristics Similar behavior for each representation

OO Polymorphism OO Application Single Interface Similar behavior for each representation