CS 331 Modules Chapter 6. Overview Decomposition and abstraction Program organization Abstract vs. concrete User-defined types Example discussion.

Slides:



Advertisements
Similar presentations
Lecture 6: Software Design (Part I)
Advertisements

Programming Languages and Paradigms
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
C++ Classes & Data Abstraction
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.
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Software Engineering and Design Principles Chapter 1.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
Guide To UNIX Using Linux Third Edition
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Lecture 8: Structured Design and Object Oriented Design CSE 111 7/12/20151Copyright William. E. Howden.
. Memory Management. Memory Organization u During run time, variables can be stored in one of three “pools”  Stack  Static heap  Dynamic heap.
Abstract Data Types and Encapsulation Concepts
Introduction SWE 619. Why Is Building Good Software Hard? Large software systems enormously complex  Millions of “moving parts” People expect software.
OOP Languages: Java vs C++
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Chapter 8 Data Abstractions Introduction to CS 1 st Semester, 2015 Sanghyun Park.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
Computer Science and Engineering College of Engineering The Ohio State University Interfaces The credit for these slides goes to Professor Paul Sivilotti.
Modularity Lecture 4 Course Name: High Level Programming Language Year : 2010.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
UHD::3320::CH121 DESIGN PHASE Chapter 12. UHD::3320::CH122 Design Phase Two Aspects –Actions which operate on data –Data on which actions operate Two.
Design Concepts By Deepika Chaudhary.
Programming Languages and Paradigms Imperative Programming.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
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.
Object-Oriented Principles Applications to Programming.
Object Oriented Programming
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
1 CS Programming Languages Class 22 November 14, 2000.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
72 4/11/98 CSE 143 Abstract Data Types [Sections , ]
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
Classes in C++ By: Mr. Jacobs. Objectives  Explore the implications of permitting programmers to define their own data types and then present C++ mechanism.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Principles of Programming & Software Engineering
TK1924 Program Design & Problem Solving Session 2011/2012
Principles of programming languages 10: Object oriented languages
SWEN421 – Lecture 3 Building High Integrity Software with SPARK Ada
Abstract Data Types and Encapsulation Concepts
Classes and OOP.
Programming with ANSI C ++
Software Engineering Fall 2005
ABSTRACT DATA TYPES Based on the fundamental concept of ABSTRACTION:
structures and their relationships." - Linus Torvalds
Stack ADT & Modularity 2 implementations of the Stack abstract data type: Array Linked List Program design: modularity, abstraction and information hiding.
ENERGY 211 / CME 211 Lecture 15 October 22, 2008.
Abstract Data Types and Encapsulation Concepts
NAME 436.
RUN-TIME STORAGE Chuen-Liang Chen Department of Computer Science
ENERGY 211 / CME 211 Lecture 18 October 31, 2008.
Lists CMSC 202, Version 4/02.
structures and their relationships." - Linus Torvalds
C++ Object Oriented 1.
Presentation transcript:

CS 331 Modules Chapter 6

Overview Decomposition and abstraction Program organization Abstract vs. concrete User-defined types Example discussion

Decomposition Break the problem down into sub-tasks “stepwise decomposition” (Parnas 72) –But how can we tell if this has been done right? –Minimize the amount of information one routine needs to have about another (low coupling) –Don’t have routines do too many things at once (high cohesion) (Constantine 78?)

Information Hiding External vs. internal behavior What a routine does vs. how the routine does it One approach: if a specification or design decision seems likely to change, then isolate those portions of the program that need to be modified Example: concrete representations of data structures

Abstraction Procedural abstraction is provided in most modern PLs –functions and procedures Data abstraction is available in some PLs A data abstraction is a set of data objects, and the set of operations defined on those objects –e.g. for a stack, operations are push, pop, isEmpty

What is a module? One definition: a module is a program construct that implements a data abstraction by associating data objects and their operations –text says “collection of variable and procedure declarations” (paraphrase of Sethi) –a module may enforce information hiding, as in C++ classes –it may be possible to compile a module separately from the program(s) which use it

External vs. Internal Behavior The external behavior of a module is provided by public members, either functions, variables or constants. (What the user sees.) The internal behavior is provided by private members, perhaps in conjunction with public members. (The internal behavior refers to how the private members interact with each other.)

Representations The abstract representation is how the user visualizes the data –matrix of real numbers, with operations such as invert() and transpose() The concrete representation is how the module implements it –a matrix may be represented as a set of row and column linked lists, for example

Invariants The set of rules that govern the external behavior are formalized in the abstract invariant –example: if isEmpty(s) then can’t do pop(s) The set of rules that govern the internal behavior is the concrete invariant –example: if malloc() returns 0, can’t do a push because the stack is full :-(

Tie it together The external behavior of a module, as provided by the public members, is governed by the abstract invariant(s) The private members, operating on the concrete representation of the object, in accordance with (the consistency rules specified in) the concrete invariant, implement the external behavior (Guttag 75)

User-defined Types If a PL allows the programmer to create modules, with the result that modules are used in the same way as if they were built into the language, then that PL supports user-defined types The PL may or may not support information hiding, or invariant checking, or overloading, or dynamic type checking...

Example: Sparse Matrices External behavior: –create a matrix A, specifying its size –access and/or modify A[i,j] for suitable i,j –iterate through a row or column of A From these operations we can print the matrix, compute its transpose, perform elementary row operations, etc.

Questions What is a suitable concrete representation? What are the private members? –Functions? Variables? Constants?? Given the private members, what is the concrete invariant? Can we provide the external behavior given the available private functions? Does the concrete invariant imply the abstract invariant?