Data Abstaraction Chapter 10.

Slides:



Advertisements
Similar presentations
Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.
Advertisements

Data Structures.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 3: Abstract Data Types.
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
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.
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Immutable Objects and Classes.
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.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Chair of Software Engineering OOSC - Lecture 4 1 Object-Oriented Software Construction Bertrand Meyer.
Object-oriented Programming Concepts
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
© 2006 Pearson Addison-Wesley. All rights reserved 4-1 Chapter 4 Data Abstraction: The Walls.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Working with Classes Chapter 6. 2 Class definition A class is a collection of data and routines that share a well-defined responsibility or provide.
C++ fundamentals.
© 2004 Pearson Addison-Wesley. All rights reserved12-1 Chapter 12 : Collections Intermediate Java Programming Summer 2007.
DATA STRUCTURE Subject Code -14B11CI211.
Data Structures and Programming.  John Edgar2.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
An Object-Oriented Approach to Programming Logic and Design
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 credit 1 lectures 10.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Chapter 9 (modified) Abstract Data Types and Algorithms Nell Dale John Lewis.
23-Oct-15 Abstract Data Types. 2 Data types A data type is characterized by: a set of values a data representation, which is common to all these values,
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
DATA STRUCTURE & ALGORITHMS (BCS 1223) NURUL HASLINDA NGAH SEMESTER /2014.
Chapter 8 Analysis & Modeling. Data Modeling examines data objects independently of processing focuses attention on the data domain creates a model at.
Data Structures and Algorithms Lecture 3 Instructor: Quratulain Date: 8 th September, 2009.
Chapter 1 Data Structures and Algorithms. Primary Goals Present commonly used data structures Present commonly used data structures Introduce the idea.
Data Structures Lecture 1: Introduction. Course Contents Data Types   Overview, Introductory concepts   Data Types, meaning and implementation  
Chapter 4 Data Abstraction: The Walls. © 2004 Pearson Addison-Wesley. All rights reserved4-2 Abstract Data Types Modularity –Keeps the complexity of a.
Linked List. Iterators Operation to find a link, deleting, and inserting before or after a specified link, also involve searching through the list to.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Abstraction ADTs, Information Hiding and Encapsulation.
Chapter 10, Slide 1 ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:  process abstraction  data abstraction Both provide:  information.
Views of Data Data – nouns of programming world the objects that are manipulated information that is processed Humans like to group information Classes,
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Data Structures Using C++ 2E
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 12 Abstract Data Type. Understand the concept of an abstract data type (ADT). Understand the concept of a linear list as well as its operations.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
Chapter 2 Principles of Programming and Software Engineering.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Data Abstraction: The Walls
DDC 2423 DATA STRUCTURE Main text:
structures and their relationships." - Linus Torvalds
Subprograms and Programmer Defined Data Type
CIS601: Object-Oriented Programming in C++
Review CSE116 2/21/2019 B.Ramamurthy.
Introduction to Data Structure
Data Abstraction: The Walls
structures and their relationships." - Linus Torvalds
Presentation transcript:

Data Abstaraction Chapter 10

Outline Concept of abstraction Abstract data types with example Encapsulation with example

The Concept of Abstraction Say what a program does without necessarily saying how it does it A process of generalization, removing restrictions, eliminating detail, removing inessential information etc “more potential implementations” – moving to a lower level mans restricting the number of potential implementations

Data types A data type is characterized by: a set of values a data representation, which is common to all these values, and a set of operations, which can be applied uniformly to all these values

Abstract Data Types (ADTs) C is not object-oriented, but we can still manage to inject some object-oriented principles into the design of C code. For example, a data structure and its operations can be packaged together into an entity called an ADT. The lower-level implementation details of the data structure are hidden from view of the rest of the program. The implementation details can be changed without altering the ADT interface.

Abstract Data Types (ADTs) Data abstraction + operation abstraction An abstract data type consists of: Data structure: stores information to represent a certain concept Functionality: set of operations that can be applied to the data type

ADT : Example As an example the description of the ADT Integer is presented. Let k be an integer expression: ADT Integer is Data A sequence of digits optionally prefixed by a plus or minus sign. We refer to this signed whole number as N. Operations constructor Creates a new integer. add(k) Creates a new integer which is the sum of N and k. Consequently, the postcondition of this operation is sum = N+k. Don't confuse this with assign statements as used in programming languages! It is rather a mathematical equation which yields ``true'' for each value sum, N and k after add has been performed. sub(k) Similar to add, this operation creates a new integer of the difference of both integer values. Therefore the postcondition for this operation is sum = N-k. set(k) Set N to k. The postcondition for this operation is N = k. ... end

Properties of Abstract Data Types The entities define the data structure of a set of items. For example, each administered employee has a name, date of birth and social number. The data structure can only be accessed with defined operations. This set of operations is called interface and is exported by the entity. An entity with the properties just described is called an abstract data type (ADT).

Properties of Abstract Data Types (con’t) Figure below shows an ADT which consists of an abstract data structure and operations. Only the operations are viewable from the outside and define the interface. Separate the use of a data structure from the details of its implementation. This is the principle underlying the use of abstract data types. Here are some examples: stack: operations are "push an item onto the stack", "pop an item from the stack", "ask if the stack is empty"; implementation may be as array or linked list or whatever. queue: operations are "add to the end of the queue", "delete from the beginning of the queue", "ask if the queue is empty"; implementation may be as array or linked list or heap. search structure: operations are "insert an item", "ask if an item is in the structure", and "delete an item"; implementation may be as array, linked list, tree, hash table, ...

Implementing an ADT To implement an ADT, you need to choose: a data representation that must be able to represent all possible values of the ADT should be private a set of methods that support normal use of the ADT The user must be able to create, possibly modify, and examine the values of the ADT an algorithm for each of the possible operations that must be consistent with the chosen representation all auxiliary (helper) operations that are not in the contract should be private

Abstract Data Types: Benefits Domain concepts are reflected in the code Encapsulation: internal complexity, data and operation details are hidden Specification vs. implementation: usage of data type is independent from its internal implementation Higher modularity Increase ease of maintenance and reuse of code

ADT : Programming example

ADT Extensibility

Encapsulation Focus on the external behavior of something and ignores the internal details of how the behavior is produced Different part of the software to be effectively isolated in operation Any component has one or more simple, well-defined external interfaces (defined in a standard)

Encapsulation and Objects

Encapsulation : Object example Optical and wired Wheeled and wireless Optical and wireless

Encapsulation : Benefits

Summary Abstraction Data Types Benefits of using ADT Encapsulation Operations Benefits of using ADT Encapsulation Implementation in C language Objects Advantages