Chapter 1 Data Abstraction: The Walls

Slides:



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

COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Software Engineering and Design Principles Chapter 1.
Introduction To System Analysis and Design
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
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.
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.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
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
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.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
C++ fundamentals.
Introduction To System Analysis and design
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.
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.
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.
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.
Designing Classes Prelude © 2015 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures and Abstractions with Java, 4e Frank.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
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 Data Abstraction: The Walls CS Data Structures Mehmet H Gunes Modified from authors’ slides.
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.
Prof. I. J. Chung Data Structure #1 Professor I. J. Chung.
Principles of Programming & Software Engineering
Data Abstraction: The Walls
Object Oriented Systems Design
Chapter 2 Object-Oriented Paradigm Overview
7. Modular and structured design
Data Abstraction: The Walls
C++ Plus Data Structures
Coupling and Cohesion 1.
Data Abstraction: The Walls
Principles of Programming and Software Engineering
About the Presentations
More about OOP and ADTs Classes
Chapter 1 Software Engineering Principles
Chapter 1 Software Engineering.
Objects First with Java
More about OOP and ADTs Classes
Slides by Steve Armstrong LeTourneau University Longview, TX
Need for the subject.
Chapter 22 Object-Oriented Systems Analysis and Design and UML
CPS120: Introduction to Computer Science
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 302 - Data Structures Modified from authors’ slides

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

Cost of an Error

Controlling Errors 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

Procedural vs. Object-Oriented Code “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

Approaches to Building Manageable Modules PROCEDURAL DECOMPOSITION OBJECT-ORIENTED DESIGN 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 FOCUS ON: processes FOCUS ON: data objects

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

Object-Oriented Design 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 cin cout >> << get Private data setf Private data . . ignore

Object-Oriented Concepts Object-oriented analysis and design (OOAD) Process for solving problems Solution Computer program consisting of system of interacting classes of objects Object Has set of characteristics, behaviors related to solution © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Object-Oriented Analysis & Design Requirements of a solution What solution must be, do Object-oriented design Describe solution to problem Express solution in terms of software objects Create one or more models of solution © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

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

Cohesion Each module should perform one well-defined task Benefits Well named, self-documenting Easy to reuse Easier to maintain More robust © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Coupling Measure of dependence among modules Dependence Sharing data structures or calling each other’s methods Modules should be loosely coupled Highly coupled modules should be avoided © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Coupling Benefits of loose coupling in a system More adaptable to change Easier to understand Increases reusability Has increased cohesion © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Specifications The task sort is a module separate from the MyProgram module © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Operation Contracts Documents Specify How method can be used What limitations it has Specify Purpose of modules Data flow among modules Pre-, post-condition, input, output of each module © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

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

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

Information Hiding Abstraction helps identify details that should be hidden from public view Ensured no other module can tamper with these hidden details. Isolation of the modules cannot be total, however Client must know what tasks can be done, how to initiate a task © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

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

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

Minimal and Complete Interfaces Interface for a class made up of publicly accessible methods and data Complete interface for a class Allows programmer to accomplish any reasonable task Minimal interface for a class Contains method if and only if that method is essential to class’s responsibilities © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

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

Abstract Data Types (ADT) Typical operations on data Add data to a data collection. Remove data from a data collection. Ask questions about the data in a data collection. An ADT : a collection of data and a set of operations on data A data structure : an implementation of an ADT within a programming language © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

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

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

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 Evolves naturally during the problem-solving process What data does a problem require? What operations does a problem require? ADTs typically have initialization and destruction operations Assumed but not specified at this stage © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

ADTs That Suggest Other ADTs You can use an ADT to implement another ADT Example: Date-Time objects available in C++ for use in various contexts Possible to create your own fraction object to use in some other object which required fractions © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

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

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 18678.92 thisCar at Base Address 6000

The ADT Bag

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

The ADT Bag Consider the bag to be an abstract data type. We are specifying an abstraction inspired by an actual physical bag Doesn’t do much more than contain its items Can unordered and possibly duplicate objects We insist objects be of same or similar types Knowing just its interface Can use ADT bag in a program © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

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

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

An Interface Template for the ADT LISTING 1-1 A file containing a C++ interface for bags © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Interface Template for the ADT LISTING 1-1 A file containing a C++ interface for bags © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

An Interface Template for the ADT LISTING 1-1 A file containing a C++ interface for bags © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Using the ADT Bag LISTING 1-2 A program for a card guessing game © 2017 Pearson Education, Hoboken, NJ.  All rights reserved

Using the ADT Bag LISTING 1-2 A program for a card guessing game © 2017 Pearson Education, Hoboken, NJ.  All rights reserved