Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

When is Orientated Programming NOT? Mike Fitzpatrick.
Data Structures.
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:
Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.
Classes & Objects Computer Science I Last updated 9/30/10.
Object-Oriented PHP (1)
CHAPTER 3 COLLECTIONS Abstract Data Types. 2 A data type consists of a set of values or elements, called its domain, and a set of operators acting on.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
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.
1 Classes and Data Abstraction Andrew Davison Noppadon Kamolvilassatian Department of Computer Engineering Prince of Songkla University.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
BACS 287 Basics of Object-Oriented Programming 1.
Object Oriented Programming
Introduction To System Analysis and design
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Introduction to Object-oriented programming and software development Lecture 1.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 24P. 1Winter Quarter C++ Lecture 24.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
Dale Roberts Object Oriented Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department.
Learners Support Publications Object Oriented Programming.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Classes and Data Abstraction Andrew Davison Noppadon Kamolvilassatian Department of Computer Engineering Prince of Songkla University 1
ADT data abstraction. Abstraction  representation of concepts by their relevant features only  programming has two major categories of abstraction process.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Chapter More on Classes Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
ENEE150 – 0102 ANDREW GOFFIN Abstract Data Types.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
COP 4331 – OOD&P Lecture 7 Object Concepts. What is an Object Programming language definition: An instance of a class Design perspective is different.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
CSCE 240 – Intro to Software Engineering Lecture 3.
ISBN Chapter 12 Support for Object-Oriented Programming.
Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Programming paradigms
Object Oriented Programming
Object-Oriented Programming Concepts
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
JAVA By Waqas.
CHAPTER 5 GENERAL OOP CONCEPTS.
Object Oriented Programming F3031
Classes and OOP.
COMPUTER 2430 Object Oriented Programming and Data Structures I
OOP What is problem? Solution? OOP
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
C++.
Object Oriented Analysis and Design
C# Object Oriented Programming Concepts
Object oriented vs procedural programming
Object-Oriented PHP (1)
CPS120: Introduction to Computer Science
Data Structures and ADTs
Presentation transcript:

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types

2 Overview: 1.What is Data Abstraction? What is ADT? 2.Model for an Abstract Data Type 3.Complex Number ADT Example 4.How Well are ADTs Supported in C? 5.C++ 6.ADT vs Object-Oriented Programming

3 1.1 What is Data Abstraction? Concept of “Abstraction” Allows us to consider the high-level characteristics of something without getting bogged down in the details For example: Process abstraction in procedural programming like C, we can use (pre-defined) functions without concern how they really works inside. Data Abstraction We know what a data type can do How it is done is hidden

4 1.2 What is an Abstract Data Type? Abstract Data Type (ADT) Defines a particular data structure in terms of data and operations Offers an interface of the objects (instances of an ADT) An ADT consists of Declaration of data Declaration of operations Encapsulation of data and operations : data is hidden from user and can be manipulated only by means of operations

5 1.3 ADT Implementation Implementaion of an Abstract Data Type (ADT) Hidden from the user Same ADT may be implemented in different ways in different languages Some languages offer built-in ADTs and/or features to be used to implement ADTs (user-define types) ADTs support modular design which is very important in software development

6 2.1 Model for an ADT Interface - Operations Data Structure System design with ADTs Problem definiton Identification of ADTs (identify data or attributes) Specify ADT operationsSpecify ADT interactions Implement ADTs Identify object hierarchy (if using OOP)

7 2.2 Clients and Manufacturers implementation interface ADT manufacturer’s responsibility client use

8 2.3 Benefits Manufacturer Benefits: easy to modify, maintain profitable reusable Client Benefits: simple to use, understand familiar cheap component–based

9 3. Complex Number ADT Example A complex number has a real part and an imaginary part. e.g.: 2+4i Interface (operations) ? create a complex number add, subtract, multiply, divide print a complex number test to see if something is complex etc.

10 Declare a complex number Interface: Complex c1, c2, c3; Possible Implementation (in C language ): struct complex { double real,imag; } typedef struct complex Complex;

11 Create a complex number Interface: c1 = create_complex(2, 3); /* conceptually, c1 = 2+3i */

12 Implementation: Complex create_complex(double real, double imag) { Complex c; c.real = real; c.imag = imag; return c; }

13 Add two complex numbers Interface: c3 = add_complex(c1, c2); /* conceptually, c3 = c1 + c2 */

14 Implementation: Complex add_complx(Complex c1, Complex c2) { Complex csum; csum.real = c1.real + c2.real; csum.imag = c1.imag + c2.imag; return csum; }

15 Using the Complex Number ADT #include /* type implementation */ struct complex { double real,imag; typedef struct complex Complex; /* operation interface */ Complex create_complex(double,double); Complex add_complex(Complex, Complex); /* other Complex prototypes print_complex()... */ continued

16 int main ( ) { Complex c1, c2, c3; c1 = create_complex(2,-3); c2 = create_complex(2,-3); c3 = add_complex(c1,c2); print_complex(c3); return 0; } /*Implementation of Complex functions */ : Using the Complex Number ADT

17 4. How Well are ADTs Supported in C? Does C enforce the use of the ADTs interface and the hiding of its implementation? No

18 5. C++ and OOP C++ is a superset of C, which has added features to support object oriented programming (OOP) C++ offers STL (Standard Templates Library) providing a set generic data structures which allow programmers to easily implement standard data structures like queues, lists, and stacks. C++ supports classes things very like ADTs Other OOP languages such as Java, Smalltalk

19 6. ADT vs Object-Oriented Programming (OOP) ADTs are not a part of a particular programming language Rather they are implemented by a programmer to solve a particular problem or some class of problems In OOP, an ADT can be easily modeled as a class An instance as an object Data of ADT as properties or fields of a class Operations as methods ADT ≠ OOP Classes in OOP offers more features than ADTs : Inheritance (Superclass-Subclass), Polymorphisms, etc.