Decomposition into modules

Similar documents
A Sketchy Evolution of Software Design. Three Papers by David Parnas

On the Criteria To Be Used in Decomposing Systems into Modules D.L. Parnas Carnegie-Mellon University

Design and Information Hiding

such a manner that we are able to understand, grasp and grapple with the problem at hand in a more organized fashion.

Contemporary Design. Traditional Hardware Design. Traditional Hardware Design. HDL Based Hardware Design User Inputs. Requirements.

Literate Programming

CMSC 132: Object-Oriented Programming II

CS 292 Software Development

Introduction to Informatics. Software Design: Flowcharts, Modular Design and Beyond

16.Greedy algorithms

Joint Entity Resolution

QUIZ on Ch.5. Why is it sometimes not a good idea to place the private part of the interface in a header file?

In his paper of 1972, Parnas proposed the following problem [42]:

SOME TYPES AND USES OF DATA MODELS

Workload Characterization Techniques

Object-Oriented and Classical Software Engineering

Object-Oriented and Classical Software Engineering

Chapter 1 Programming: A General Overview

PLD Semester Exam Study Guide Dec. 2018

Programming II. Modularity 2017/18

Section 1.7 Sequences, Summations Cardinality of Infinite Sets

Lecture 3. Parnas Information Hiding

Managing Change and Complexity

Specification and Analysis of Contracts Tutorial

Hash Table and Hashing

Software Design Fundamentals. CSCE Lecture 11-09/27/2016

CHAPTER 9 DESIGN ENGINEERING. Overview

Section 2.4 Sequences and Summations

Verification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80

Chapter 11: Indexing and Hashing

Checklist for Requirements Specification Reviews

Chapter 1 Programming: A General Overview

A Brief History of Modularity in Programming

Chapter 11: Indexing and Hashing

is easing the creation of new ontologies by promoting the reuse of existing ones and automating, as much as possible, the entire ontology

CS240: Programming in C

What Parnas72 Means for D. Luís Marques, DConf 2016, May 4th 2016

Where are we going? EEC 421/521: Software Engineering. What is Design? A Note on Quality. Introduction to Design. Many levels of design: Our focus

WHAT IS SOFTWARE ARCHITECTURE?

UNIT II Requirements Analysis and Specification & Software Design

Chapter 12: Indexing and Hashing. Basic Concepts

Module 5. Function-Oriented Software Design. Version 2 CSE IIT, Kharagpur

Layers. External Level Conceptual Level Internal Level

Indicate the answer choice that best completes the statement or answers the question. Enter the appropriate word(s) to complete the statement.

Week 6: Data. Let's focus first on application domain data.

NOTICE WARNING CONCERNING COPYRIGHT RESTRICTIONS: The copyright law of the United States (title 17, U.S. Code) governs the making of photocopies or

Chapter 12: Indexing and Hashing

Complexity. Object Orientated Analysis and Design. Benjamin Kenwright

Final Exam Review (extended)

Lecture 14: Lower Bounds for Tree Resolution

COUNTING AND PROBABILITY

A macro- generator for ALGOL

A Template for an Assurance Case Shall Be Known as an Assurance Case Template

TABLES AND HASHING. Chapter 13

Self-study session 1, Discrete mathematics

A Brief History of Modularity in Programming

Chapter 2 - Control Structures

So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees.

Course Roadmap. Architecture and Design. Final Requirements Review. Preliminary Requirements Review. Peer Evaluations. Architecture Presentations

CSC 330 Object Oriented Software Design. Software Design Phase

CS 137 Part 8. Merge Sort, Quick Sort, Binary Search. November 20th, 2017

Job Re-Packing for Enhancing the Performance of Gang Scheduling

Algorithms. Algorithms 1.4 ANALYSIS OF ALGORITHMS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Hashing. Manolis Koubarakis. Data Structures and Programming Techniques

Treewidth and graph minors

21) Functional and Modular Design

Programming Languages

Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

21) Functional and Modular Design

Dynamic Programming II

Week 11: Minimum Spanning trees

CSE 421 Applications of DFS(?) Topological sort

What are the characteristics of Object Oriented programming language?

ECE468 Computer Organization & Architecture. The Design Process & ALU Design

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Chapter 11: Indexing and Hashing" Chapter 11: Indexing and Hashing"

Chapter 1. Introduction

Object-Oriented Programming and Laboratory of Simulation Development

Modularity. Modular program development. Language support for modularity. Step-wise refinement Interface, specification, and implementation

Verification and Validation. Verification and validation

Incompatibility Dimensions and Integration of Atomic Commit Protocols

Object-Oriented Analysis and Design Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology-Kharagpur

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

CS350 Lecture 2 Requirements Engineering. Doo-Hwan Bae

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

An Overview of the BLITZ System

Optimization I : Brute force and Greedy strategy

Topics in Software Testing

CHAPTER 3: FUNDAMENTAL OF SOFTWARE ENGINEERING FOR GAMES.

Programming (1.0hour)

Software Architecture in Practice

Introduction to Algorithms

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

A Small Interpreted Language

Chapter 9. Introduction to High-Level Language Programming. INVITATION TO Computer Science

AN INTEGRATED DEVELOPMENT / RUN-TIME ENVIRONMENT

Chapter 11: Indexing and Hashing

The architecture of Eiffel software 3.1 OVERVIEW classes clusters systems

Transcription:

Programming Languages Seminar Program Structure and readability Lefel Yaniv Hagay Pollak 1 Decomposition into modules On the criteria to be used in decomposing systems into modules by D.L.Parnas.(1972) 2 1

Introduction The philosophy of modular programming (1970) Segmentation of project effort. System modularity. Inputs and outputs are well defined. Module integrity is tested independently. System is maintained in modular fashion. System errors and deficiencies can be traced to specific modules. Limiting the scope of detailed error searching. 3 Modular programming advancement Major advancement in modular programming: A module can be written with little knowledge of code in another module. Modules can be replaced without reassembly of the whole system. 4 2

Benefits of modular programming Managerial development time reduced. Product flexibility one module can be changed independently of others. Comprehensibility System is better designed because it is better understood. 5 What is modularization? Modularization: partial system description, design decisions made prior to commence of work. Module a responsibility assignment 6 3

What are the criteria to be used in dividing the system into modules? 7 Input: An order set of lines. Each line is an ordered set of words, Each word is an ordered set of characters. Output: Case study: KWIC index description Listing of all circular shifts of all lines in alphabetical order. 8 4

KWIC index Modularization 1 Example: Input AA CC BBB CDCD ABA Output AA CC BBB BBB AA CC CC BBB AA ABA CDCD CDCD ABA 9 Case study: KWIC index remarks Such a system could be produced by a good programmer within a week or two. We must go through the exercise of treating this problem as if it were a large project. 10 5

KWIC index Modularization 1 Module 1: Input Read the input into a memory. Create a list of pointers which point to the beginning of each line. Module 2: Circular Shift. Prepares an index of the first characters of each circular shift. Eventually creating a list of pairs (line number, starting address). 11 KWIC index Modularization 1 Cont Example (module 2) Original line: Line 2: BBB AA CC Module 2 output for line 2: BBB AA CC AA CC BBB CC BBB AA Represented by (2,+0),(2,+4),(2,+7). 12 6

KWIC index Modularization 1 Cont Module 3: Alphabetizing. Takes the arrays produced by modules 1,2. Arranges the circular shifts in alphabetically order. New data is kept in same format as in module 2. 13 KWIC index Modularization 1 Cont Example (module 3) Original data set: (2,+0),(2,+4),(2,+7). Alphabetically sorted set: (2,+4),(2,+0),(2,+7) Before (2,+0),(2,+4),(2,+7) BBB AA CC AA CC BBB CC BBB AA After (2,+4),(2,+0),(2,+7) AA CC BBB BBB AA CC CC BBB AA 14 7

KWIC index Modularization 1 Cont Module 4: Output. Listing circular shifts. Module 5: Master Control Control sequencing (modules 1,2,3,4). Handle error messages, space allocation, etc. 15 KWIC index Modularization 1 scheme Control Circular Input Alphabetizing Output Shift Modularization 1 scheme 16 8

KWIC index Modularization 2 Module 1: Line Storage Handles all data storage of the lines and characters. Module 2: Input. Reads lines from input. Calls Line Storage module to store the lines in the memory. Module 3: Circular Shift. Function CSSETUP() must be called before the used of other functions in the module. Function CSCHAR(I,w,c) provides the value representing the cth character in the wth word of the Ith circular shift of all lines. Other functions TBD. 17 KWIC index Modularization 2 Module 4: Alphabetizer Function ALPH performs module setup. Function ITH(i) returns the index of the circular shift line which comes ith in the alphabetical ordering. Module 5: Output Provides interface for printing the desired output. Module 6: Master Control. Similar to modularization 1. 18 9

KWIC index Modularization 2 Static Model Line Storage Circular Input Alphabetizer Output Control Shifter Modularization 2 scheme * Additional internal connections might exist. 19 KWIC index Modularization 2 Dynamic Model Control Input Output Alphabetizer Circular Shifter Line Storage 20 10

Modularization comparison Commonalities Both decompositions will work. Both provide a well defined segmentation of the system. The decompositions are identical in the runnable representation (same output). 21 Modularization comparison Dissimilarities The two decompositions have different representations for Changing Documenting Understanding Etc. Other representations are part of the system, and not only the running part. 22 11

Modularization comparison Changeability Design decisions which are likely to change (partial list): Input format Data structure Function (method) implementation Sequencing of events (setup and build a list or trace data according to demand) 23 Modularization comparison KWIC Changeability examples Modular Change Input format Data packing Circular shift format Alphabetizing I Input module All modules Alphabetizer, output, circular shifting modules Output, alphabetizer II Input module Line Storage module Circular shifter module Alphabetizer 24 12

Modularization comparison Independent Development Modularization I Modules share the same physical data structure. The development of data formats will be a joint effort by the development groups. Modularization II Abstract interfaces, consist mainly in function names and parameters. Relatively simple decisions required, thus development of modules begins earlier (than in modularization I). 25 Modularization comparison Comprehensibility Modularization I The system will only be comprehensible as a whole. Modularization II Each module is independent. To understand a module, one needs only to understand the module, and the interfaces to other modules. 26 13

Decompositions - Criteria used Modularization I Each module is a major step in the processing. Modules derive from a flowchart. Modularization II Information hiding used both for data and for implementation. 27 Decompositions - Criteria offered (encapsulating into modules) Data structure and accessing functions. Similar data should be hidden in a module. Sequence of instructions. Sequence of processing of data items. 28 14

Decompositions - Efficiency The separation between modules is required for the readability representation, not in the running representation of the program. Inter module function calls raise procedure call overhead. Can be improved by compiler - time optimization. 29 Hierarchical structure Hierarchical structure is used if a module uses or depends on another module. Hierarchical structure and decomposition are two independent properties of system structure. Benefits of partial ordering: Higher levels of the system are simplified since they use the services of lower levels. Ability to replace system components in the hierarchical structure. 30 15

Conclusion It is incorrect to decompose the system into modules on the basis of a flowchart. Modules will not necessarily correspond to steps in the processing. Build a list of design decision likely to change. Each module is designed to hide such decisions from the others. Assemble programs as a collection of code from various modules. 31 Structured programming By Edsger W. Dijkstra (1969) 32 16

Introduction Is it possible to increase programming ability? What techniques should then be applied in the process of program composition? 33 Program size This discussion is concerned with programs that are large due to complexity of their task. Consider a program including N modules. Let us assume the probability of correctness of each module is p. Therefore the probability of correctness of the program is Q = p^n. 34 17

Program size For a large N, p must be close to 1, if Q is to differ significantly from 0. Combining subsets into large components does not improve the correctness of the program. p^(n/2)*p^(n/2) = p^n= Q. 35 Program size family of programs A large program is always a series of versions of the program. Different versions perform the same and/or similar tasks. We consider a program to be a member of a family, sharing components, correctness and substructure. 36 18

Program correctness Program testing can be used to show the presence of bugs, but never to show their absence. Program correctness should be proved on account of the program text. 37 Program correctness Program correctness can be proved. The effort required to prove program correctness may grow exponentially with program growth. 38 19

The relation between program and computation When programs are expressed as linear sequence of statements, sequencing should not be controlled by statements transferring control to labeled points (e.g. goto statements). 39 The relation between program and computation Let us consider a program, P1, of the form: S 1, S 2, S 3,, S N ; where S i, is an individual statement. N steps of reasoning are needed to establish the correctness of P1. For the statement: if B then S 1 else S 2, 2 steps of reasoning are needed. 40 20

The relation between program and computation Let P2 be the program: if B 1 then S 11 else S 12 if B 2 then S 21 else S 22 if B N then S N1 else S N2 To reduce P2 to the form of P1 it takes 2N steps. And then another N steps to understand the form of P1. Altogether 3N steps. 41 The relation between program and computation Trying to understand the algorithm as S ij would lead to N*2^N steps of reasoning. Explanation: for each N statements consider 2^N options of executions. Conclusion: programs of the form P1 are preferable for step-wise abstraction. 42 21

Abstract data structures Abstract data structures and abstract statements (e.g. routines) represent design decisions. They are the natural unit of interchange for program modification. Let us call such a unit - a pearl. 43 Programs as necklaces strung from pearls A program is an ordered set of pearls a necklace. The top pearl describes the program in its most abstract form. Lower pearls define and refine the upper pearls. Pearl seems to be a natural program module. 44 22

Programs as necklaces strung from pearls Specific design decision is actually an aspect of original problem statement. A pearl embodies specific design decision. Lower half of a necklace is the implementation of the upper half. Thus, the correctness of the upper half of the necklace can be established regardless of the choice of the bottom half. 45 Programs as necklaces strung from pearls The family of programs is the set of selections from a collection of pearls that can be strung into a necklace. 46 23

Conclusion Testing of a program is not a proof of correctness. The proof process requires abstraction of the statements. Design using the pearl model provides the abstraction required for the proof of correctness. 47 Goto statement Goto statement considered harmful By Edsger W. Dijkstra (1968) 48 24

Motivation A programmer s activity seems to end when he constructed a correct program. A process is the dynamic behavior of a program. The main issue of the program is its process. 49 Motivation cont A program is the static description of a process. Our powers to visualize dynamic behavior are poorly developed. Our objective is to shorten the conceptual gap between the static program and the dynamic process. 50 25

Process progress Suppose a process stopped during execution, how can we redo the process to the same point? 51 Process progress Consider a program which includes assignments and conditional clauses. It is sufficient to point to the relevant text. Such a pointer will be called: textual pointer. 52 26

Process progress cont As we include procedures in the program, we also have to give an index to the procedure call. We characterize the progress of the process by a sequence of textual indices. 53 Process progress cont As we include repetition clauses in the program, we use dynamic indexing. Each entry into a repetition clause changes the index. The dynamic index enables counting of repetitions. The progress of the process is uniquely described by a (mixed) sequence of textual and/or dynamic indices. 54 27

Process progress cont We have a defined a coordinate system, describing the progress of the process. Now we can evaluate every variable in the program. 55 Goto statements Goto statements make it hard to find a meaningful coordinate system describing the progress of the process. The difficulty is that such a system, although unique is still unhelpful. We can t maintain a list of goto calls, as we did in the function calls, since the return locations are hard to trace. 56 28

Conclusion Goto statements make it hard to understand, read the code, and analyze the progress of the process. Since one of the roles of the program is the text representation, use of goto statements misses the program goals and should not be used. 57 Discussion 58 29