Chapter 1 Data Abstraction: The Walls CS 302 - Data Structures Mehmet H Gunes Modified from authors’ slides.

Slides:



Advertisements
Similar presentations
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Advertisements

6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
Software Engineering and Design Principles Chapter 1.
Introduction To System Analysis and Design
Fall 2007CS 225 Introduction to Software Design Chapter 1.
Important Definitions Class: A structured data type that is used to represent an abstract data type (ADT) Class member: A components of a class. It can.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
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.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
Chapter 1 Principles of Programming and Software Engineering.
Chapter 1 Software Engineering. Homework ► Read Section 2.2 (pages 79-98) ► Answer questions: ► 7, 8, 11, 12, & 13 on page 134. ► Answer on paper, hand.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Software Engineering Principles and C++ Classes
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Data Abstraction: The Walls
© 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.
C++ fundamentals.
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.
1 Basic Concepts of Object-Oriented Design. 2 What is this Object ? There is no real answer to the question, but we ’ ll call it a “ thinking cap ”. l.
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Introduction to Software Design Chapter 1. Chapter Objectives  To become familiar with the software challenge and the software life cycle  To understand.
1 Chapter-01 Programming Methodologies Procedural/Structured Design Objected-Oriented Design.
Data Structures and Abstractions with Java, 4e Frank Carrano
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
Chapter 1 Software Engineering Principles. Lecture 2.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
1 Life Cycle of Software Specification Design –Risk Analysis –Verification Coding Testing –Refining –Production Maintenance.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Data Structures Using C++1 Chapter 1 -Software Engineering Principles -ADT and Classes.
1 Chapter Structured Types, Data Abstraction and Classes Dale/Weems.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
1 2 Data Design and Implementation Chapter 2 Data Design 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.
Lists Chapter 4 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved More about.
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.
Data Structures Using C++ 2E
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
Chapter 2 Principles of Programming and Software Engineering.
CSC 205 Java Programming II Abstract Data Type. Abstraction The meaning of abstraction Abstraction arises from a recognition of similarities between certain.
Principles of Programming & Software Engineering
Data Abstraction: The Walls
Data Abstraction: The Walls
C++ Plus Data Structures
Data Abstraction: The Walls
Chapter 1 Data Abstraction: The Walls
Principles of Programming and Software Engineering
About the Presentations
Chapter 1 Software Engineering Principles
Chapter 1 Software Engineering.
Slides by Steve Armstrong LeTourneau University Longview, TX
Adapted from Pearson Education, Inc.
Copyright ©2012 by Pearson Education, Inc. All rights reserved
© 2016 Pearson Education, Ltd. All rights reserved.
Presentation transcript:

Chapter 1 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides

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, ©

The Software Life Cycle Problem analysis Requirements elicitation Software specification High- and low-level design Implementation Testing and Verification Delivery Operation Maintenance 3

Cost of an Error 4

Robustness: The ability of a program to recover following an error – the ability of a program to continue to operate within its environment Preconditions: Assumptions that must be true on entry into an operation or function for the postconditions to be guaranteed Postconditions: Statements that describe what results are to be expected at the exit of an operation or function – assuming that the preconditions are true Controlling Errors 5

“Read the specification of the software you want to build. Underline the verbs if you are after procedural code, the nouns if you aim for an object-oriented program.” Grady Booch, “What is and isn’t Object Oriented Design,” 1989 Procedural vs. Object-Oriented Code 6

Divides the problem into more easily handled subtasks, until the functional modules (subproblems) can be coded Identifies various objects composed of data and operations, that can be used together to solve the problem Approaches to Building Manageable Modules PROCEDURAL DECOMPOSITION OBJECT-ORIENTED DESIGN FOCUS ON: processes FOCUS ON: data objects 7

Functional Design Modules Find Weighted Average Print Weighted Average Main Print Data Print Heading Get Data Prepare File for Reading 8

A technique for developing a program in which the solution is expressed in terms of objects – self- contained entities composed of data and operations on that data Object-Oriented Design Private data << setf Private data >> get ignore cin cout 9

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, ©

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, ©

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, ©

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, ©

Specifications Operation Contracts Unusual Conditions Abstraction Information Hiding Minimal and Complete Interfaces Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, ©

Operation Contract Documents use and limitations of a method – purpose, assumptions, input, output Specifies data flow Does not specify how module will perform its task Specifies pre- and post-conditions Precise documentation is essential Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, ©

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, © !!! Has security implications !!!

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, ©

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

Minimal and Complete Interfaces Signature – function’s name; – the number, order, and type of arguments; – any qualifiers such as const Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, ©

Data The representation of information in a manner suitable for communication or analysis by humans or machines Data are the nouns of the programming world: – The objects that are manipulated – The information that is processed 20

Abstract Data Type A collection of data and A set of operations on the data A data type whose properties (domain and operations) are specified independently of any particular implementation Carefully specify an ADT’s operations before you implement them Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, ©

Abstract Data Type ADT is a specification for a group of values and the operations on those values A dispenser of chilled water, crushed ice, and ice cubes Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, ©

Abstract Data Type 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, ©

Data from 3 different levels Application (or user) level: modeling real-life data in a specific context. WHY Logical (or ADT) level: abstract view of the domain and operations. WHAT Implementation level: specific representation of the structure to hold the data items, and the coding for operations. HOW

Collection ordered in different ways

Viewing a library from 3 different levels Application (or user) level: Library of Congress, or Baltimore County Public Library. Logical (or ADT) level: domain is a collection of books; – operations include: check book out, check book in, pay fine, reserve a book. Implementation level: representation of the structure to hold the “books”, and the coding for operations.

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, ©

Composite array struct union class Address pointer reference Simple IntegralFloating char short int long enum float double long double C++ Built-In Data Types

Records A composite data type made up of a finite collection of not necessarily homogeneous elements called members or fields For example....year 2008.maker ‘h’‘o’‘n’‘d’ ‘a’‘\0’....price thisCar at Base Address 6000

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, ©

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, ©

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, ©

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

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

The ADT Bag View code listing for Bag interface, – Listing 1-1 Listing 1-1 Note use of ADT Bag, Program for Card Guessing – Listing 1-2 Listing 1-2 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, ©