Data Abstraction: The Walls

Slides:



Advertisements
Similar presentations
Lists Chapter 8 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Advertisements

Graphs Chapter 20 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Queues and Priority Queues
Software Engineering and Design Principles Chapter 1.
Lists Chapter 4. 2 Chapter Contents Specifications for the ADT List Redefining the Specifications Using the ADT List Using a List Is Like Using a Vending.
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.
Overview. Why data structures is a key course Main points from syllabus Survey Warmup program And now to get started...
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Sorted Lists and Their Implementations Chapter 12 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Stacks Chapter 6 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Data Abstraction and Problem Solving with C++ Walls and Mirrors, Third Edition, Frank M. Carrano and Janet J. Prichard ©2002 Addison Wesley CHAPTER 3 Data.
Queues and Priority Queues
Implementations of the ADT Stack Chapter 7 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 6 Stacks CS Data Structures Mehmet H Gunes Modified from authors’ slides.
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Trees Chapter 15 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Algorithm Efficiency Chapter 10 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Data Structures and Abstractions with Java, 4e Frank Carrano
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Tree Implementations Chapter 16 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Designing Classes Prelude © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank.
April 24, 2017 Chapter 4 Data Abstraction The Walls
Chapter 4 Data Abstraction: The Walls. © 2004 Pearson Addison-Wesley. All rights reserved4-2 Abstract Data Types Modularity –Keeps the complexity of a.
Lists Chapter 4 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
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.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 3 Collections. Objectives  Define the concepts and terminology related to collections  Explore the basic structures of the Java Collections.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Heaps Chapter 17 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Data Abstraction and Problem Solving with JAVA Walls and Mirrors Frank M. Carrano and Janet J. Prichard © 2001 Addison Wesley Data Abstraction and Problem.
Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
COP3530 Data Structures300 Data Abstraction: The Walls Abstract Data Types (ADT) Specifying ADTs –The ADT List –The ADT Sorted List –Designing an ADT Implementation.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
C++ Classes C++ Interlude 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Graphs. Contents Terminology Graphs as ADTs Applications of Graphs.
Array-Based Implementations Chapter 3 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Chapter 2 Principles of Programming and Software Engineering.
Queues and Priority Queue Implementations Chapter 14 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Link Based Implementations
Principles of Programming & Software Engineering
Data Abstraction: The Walls
Data Abstraction: The Walls
DATA ABSTRACTION AND PROBLEM SOLVING WITH C++
Abstract Data Types (ADT)
Data Abstraction: The Walls
Chapter 1 Data Abstraction: The Walls
Principles of Programming and Software Engineering
C++ Classes C++ Interlude 1
Exceptions C++ Interlude 3
INFS 6225 – Object-Oriented Systems Analysis & Design
Stacks Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
List Implementations Chapter 9
Slides by Steve Armstrong LeTourneau University Longview, TX
Adapted from Pearson Education, Inc.
Stacks Chapter 6 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Abstract Data Types (ADT)
Sorted Lists and Their Implementations
Array-Based Implementations
Copyright ©2012 by Pearson Education, Inc. All rights reserved
Data Abstraction: The Walls
© 2016 Pearson Education, Ltd. All rights reserved.
Presentation transcript:

Data Abstraction: The Walls Chapter 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Contents Object-Oriented Concepts Achieving a Better Solution Specifications Abstract Data Types The ADT Bag Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Object-Oriented Concepts Code using a solution design Specify a system of interacting objects Object-oriented analysis specifies What to do Not how to do it Object-oriented design specifies Models of how it might be done Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Object-Oriented Solution Create a good set of modules Store, move, alter data Communicate with one another Use classes of objects Combines attributes and behaviors Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Principles of Object-Oriented Programming Encapsulation: Objects combine data and operations. Inheritance: Classes inherit properties from other classes. Polymorphism: Objects determine appropriate operations at execution. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Achieving a Better Solution Cohesive modules perform single well-defined tasks Coupling – measure of dependence among modules Loosely coupled modules desired Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Achieving a Better Solution FIGURE 1-1 The task sort is a module separate from the MyProgram module Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Operation Contract Documents use and limitations of a method Specifies data flow Does not specify how module will perform its task Specifies pre- and post-conditions Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Unusual Conditions Options Assume they never happen Ignore invalid situations Guess at client’s intent Return value that signals a problem Throw an exception Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Abstraction Separates purpose of a module from its implementation Possible to use a module without knowing implementation Think “what” not “how” Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

FIGURE 1-2 Tasks communicate through a slit in wall Information Hiding FIGURE 1-2 Tasks communicate through a slit in wall Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Minimal and Complete Interfaces FIGURE 1-3 A revised implementation communicates through the same slit in the wall Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Abstract Data Type A collection of data and A set of operations on the data. Carefully specify an ADT’s operations before you implement them Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

FIGURE 1-4 A dispenser of chilled water, crushed ice, and ice cubes Abstract Data Type FIGURE 1-4 A dispenser of chilled water, crushed ice, and ice cubes Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Abstract Data Type FIGURE 1-5 A wall of ADT operations isolates a data structure from the program that uses it Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Designing an ADT Ask the questions What data does the problem require? Names IDs Numerical data What operations will be done on that data? Initialize Display Calculations Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

The ADT Bag A bag is a container Contains finite number of data objects All objects of same type Objects in no particular order Objects may be duplicated Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Identifying Behaviors Get the number of items currently in the bag. See whether the bag is empty. Add a given object to bag. Remove occurrence of specific object from bag Remove all objects from bag. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Identifying Behaviors Count the number of times certain object occurs in bag. Test whether bag contains particular object. Look at all objects in bag. Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Identifying Behaviors FIGURE 1-6 A CRC card for a class Bag Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

Specifying Data and Operations FIGURE 1-7 UML notation for the class Bag Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

The ADT Bag View code listing for Bag interface, Note use of ADT Bag, Program for Card Guessing Listing 1-2 .htm code listing files must be in the same folder as the .ppt files for these links to work Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013

End Chapter 1 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013