Modularity!! Guidelines for design! in any programming language!

Similar documents
Modularity Guidelines for design in any programming language

Setting the stage... Key Design Issues. Main purpose - Manage software system complexity by improving software quality factors

LECTURE 3: SOFTWARE DESIGN. Software Engineering Mike Wooldridge

CAS 703 Software Design

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

Software Design. Levels in Design Process. Design Methodologies. Levels..

Lecturer: Sebastian Coope Ashton Building, Room G.18

Elementary Concepts of Object Class

CHAPTER 5 GENERAL OOP CONCEPTS

Software Architecture Bertrand Meyer. Lecture 3: Language constructs for modularity and information hiding

CS 292 Software Development

CHAPTER 9 DESIGN ENGINEERING. Overview

Design and Information Hiding

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

Programming II. Modularity 2017/18

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

CS560: Formal Modelling and Implementation of Systems (Term II)

PC204. Lecture 5 Programming Methodologies. Copyright 2000 by Conrad Huang and the Regents of the University of California. All rights reserved.

Object-Oriented Design

Programming II (CS300)

CS211 Lecture: Design Quality; Cohesion and Coupling; Packages

EINDHOVEN UNIVERSITY OF TECHNOLOGY

What are Metrics?! Functions, that assign a precise numerical value to. Detecting Design Problems using Metrics

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

Chapter 5 Object-Oriented Programming

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

Software Metrics and Design Principles. What is Design?

Contemporary Multilevel Machines

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

21) Functional and Modular Design

Software Engineering Principles

Information Hiding and Aspect-Oriented Modeling

An Introduction to Software Architecture By David Garlan & Mary Shaw 94

21) Functional and Modular Design

Architectural Decomposition Mei Nagappan

Architectural Decomposition Reid Holmes

Unit-3 Software Design (Lecture Notes)

Object-Oriented Concepts and Design Principles

CMPT Data and Program Organization

Presenter: Dong hyun Park

Introduction to Programming

Object-Oriented Design

Establishing the overall structure of a software system

Chapter 8: Class and Method Design

CSC 330 Object Oriented Software Design. Software Design Phase

Objectives. Architectural Design. Software architecture. Topics covered. Architectural design. Advantages of explicit architecture

Exam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E

System Design and Modular Programming

Desired Characteristics of Modules. Stefan Resmerita, WS2015

Obfuscating Transformations. What is Obfuscator? Obfuscation Library. Obfuscation vs. Deobfuscation. Summary

Sub- PPL Unit-I Class-SE Comp

Topic : Object Oriented Design Principles

Object Orientated Analysis and Design. Benjamin Kenwright

Reasoning About Imperative Programs. COS 441 Slides 10

Introduction to Object-Oriented Programming

Complexity. Object Orientated Analysis and Design. Benjamin Kenwright

Programmazione. Prof. Marco Bertini

Principles of Software Construction: Objects, Design and Concurrency. Introduction to Design. toad

301AA - Advanced Programming [AP-2017]

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

Classes and Objects. Object Orientated Analysis and Design. Benjamin Kenwright

Computational Expression

Lecturer: William W.Y. Hsu. Programming Languages

MCQS for Midterm cs504 Combined by Anees Ahmad

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles

Java and Software Design

Design Engineering. Overview

Object Oriented Software Design

Architectural Decomposition & Representations Reid Holmes

Unit - IV CHAPTER - 13 INTRODUCTION TO OOP WITH C++ Part 1 Choose the best answer

Design Patterns. Gunnar Gotshalks A4-1

Chapter 2 Basic Principles of the Object-Oriented Paradigm 2.1 Abstraction

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT. Object Oriented Programming

Introduction to System Design

Object-Oriented and Classical Software Engineering DESIGN 11/12/2017. CET/CSC490 Software Engineering Design CHAPTER 14. Stephen R. Schach.

The object-oriented approach goes a step further by providing tools for the programmer to represent elements in the problem space.

Introduction to Computer Science and Business

Design Process Overview. At Each Level of Abstraction. Design Phases. Design Phases James M. Bieman

1: Introduction to Object (1)

Object-Oriented and Classical Software Engineering

Lecture 4: Design Concepts For Responsibility- Driven Design Kenneth M. Anderson January 20, 2005

Session 4b: Review of Program Quality

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

Lecture 20: Implementation () / 33

Programming Languages & Paradigms PROP HT Abstraction & Modularity. Inheritance vs. delegation, method vs. message. Modularity, cont d.

17.11 Bean Rules persistent

Towards a Memory-Efficient Knapsack DP Algorithm

Software Architecture

CS 575: Software Design

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Modules. Cardelli, 1996

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

5/9/2014. Recall the design process. Lecture 1. Establishing the overall structureof a software system. Topics covered

PRINCIPLES OF SOFTWARE DESIGN

Scala, Your Next Programming Language

A few more things about Agile and SE. Could help in interviews, but don t try to bluff your way through

Intro to: Design Principles

Object-Oriented Modeling Using UML. CS151 Chris Pollett Aug. 29, 2005.

Introduction to Object Oriented Programming. (Hebrew University, CS / Spring 2012 )

Transcription:

Modularity!! Guidelines for design! in any programming language! 14-1!

Modular Software! Software constructed as assemblies of small pieces! 14-2!

Modular Software 2! Software constructed as assemblies of small pieces!» Each piece encompasses the data and operations necessary to do one task well! 14-3!

Modular Software 3! Software constructed as assemblies of small pieces!» Each piece encompasses the data and operations necessary to do one task well! Modular software ==> maintainable software!» Uses divide and conquer principle! 14-4!

Modular Software 4! Software constructed as assemblies of small pieces!» Each piece encompasses the data and operations necessary to do one task well! Modular software ==> maintainable software!» Uses divide and conquer principle! Meyer:!» To achieve extendibility, reusability, compatibility, need modular software and methods to produce modular software! 14-5!

Modular Software 5! Software constructed as assemblies of small pieces!» Each piece encompasses the data and operations necessary to do one task well! Modular software ==> maintainable software!» Uses divide and conquer principle! Meyer:!» To achieve extendibility, reusability, compatibility, need modular software and methods to produce modular software! In OO design!!!non-oo design!» Module! Class!!!Module! File! 14-6!

Information hiding! Issues in Modular Design! 14-7!

Issues in Modular Design 2! Information hiding!» Client sees only interface! 14-8!

Issues in Modular Design 3! Information hiding!» Client sees only interface! Independence! 14-9!

Issues in Modular Design 4! Information hiding!» Client sees only interface! Independence!» Each module implements a separable part of the whole! 14-10!

Issues in Modular Design 4! Information hiding!» Client sees only interface! Independence!» Each module implements a separable part of the whole!» Modules have small, simple interfaces! 14-11!

Issues in Modular Design 5! Information hiding!» Client sees only interface! Independence!» Each module implements a separable part of the whole!» Modules have small, simple interfaces!» High interaction between modules is usually symptomatic of a bad modular design! 14-12!

Cohesion & Coupling! Key ideas for measuring modularity! 14-13!

Cohesion & Coupling 2! Key ideas for measuring modularity!» Cohesion! > How "self contained" is a module! 14-14!

Cohesion & Coupling 3! Key ideas for measuring modularity!» Cohesion! > How "self contained" is a module! > No extraneous bits & pieces! 14-15!

Cohesion & Coupling 4! Key ideas for measuring modularity!» Cohesion! > How "self contained" is a module! > No extraneous bits & pieces!» Coupling! > How dependent modules are on each other! 14-16!

Cohesion & Coupling 5! Key ideas for measuring modularity!» Cohesion! > How "self contained" is a module! > No extraneous bits & pieces!» Coupling! > How dependent modules are on each other! > Size of the common interface! Do you want high or low cohesion and coupling? 14-17!

Cohesion & Coupling 5! Key ideas for measuring modularity!» Cohesion! > How "self contained" is a module! > No extraneous bits & pieces!» Coupling! > How dependent modules are on each other! > Size of the common interface! Want high cohesion and low coupling 14-18!

Criteria for Modularity! Want a modular design method satisfying!» Decomposability! 14-19!

Criteria for Modularity 2! Want a modular design method satisfying!» Decomposability!» Composability! 14-20!

Criteria for Modularity 3! Want a modular design method satisfying!» Decomposability!» Composability!» Understandability! 14-21!

Criteria for Modularity 4! Want a modular design method satisfying!» Decomposability!» Composability!» Understandability!» Continuity! 14-22!

Criteria for Modularity 5! Want a modular design method satisfying!» Decomposability!» Composability!» Understandability!» Continuity!» Protection! 14-23!

Criteria for Modularity 6! Want a modular design method satisfying!» Decomposability!» Composability!» Understandability!» Continuity!» Protection! Without these, we cannot produce modular software! 14-24!

Decomposability! Decomposition!» Break a problem into sub-problems connected by simple structures! 14-25!

Decomposability 2! Decomposition!» Break a problem into sub-problems connected by simple structures! > Minimize communication between sub-problems! 14-26!

Decomposability 3! Decomposition!» Break a problem into sub-problems connected by simple structures! > Minimize communication between sub-problems! > Permit further work to proceed separately on each sub-problem! 14-27!

Decomposability 4! Decomposition!» Break a problem into sub-problems connected by simple structures! > Minimize communication between sub-problems! > Permit further work to proceed separately on each sub-problem!» Example! > See slides on top down design! 14-28!

Composability! Composition!» Produce software from reusable plug and play modules! 14-29!

Composability 2! Composition!» Produce software from reusable plug and play modules!» Composed software is itself a reusable module! 14-30!

Composability 3! Composition!» Produce software from reusable plug and play modules!» Composed software is itself a reusable module!» Reusable modules work in environments different from the ones in which they were developed! 14-31!

Composability 4! Composition!» Produce software from reusable plug and play modules!» Composed software is itself a reusable module!» Reusable modules work in environments different from the ones in which they were developed!» Examples! > Using pipe in the Unix shell to combine Unix commands! 14-32!

Composability 5! Composition!» Produce software from reusable plug and play modules!» Composed software is itself a reusable module!» Reusable modules work in environments different from the ones in which they were developed!» Examples! > Using pipe in the Unix shell to combine Unix commands! > See slides on abstract data types and bottom-up design! 14-33!

Decomposability and Composability! Composability and decomposability are independent and often at odds! 14-34!

Decomposability and Composability 2! Composability and decomposability are independent and often at odds!» Top down design favours generating modules that fulfill specific requirements! 14-35!

Decomposability and Composability 3! Composability and decomposability are independent and often at odds!» Top down design favours generating modules that fulfill specific requirements! > Unsuitable for composition! 14-36!

Decomposability and Composability 4! Composability and decomposability are independent and often at odds!» Top down design favours generating modules that fulfill specific requirements! > Unsuitable for composition!» Bottom up design favours general modules that are too general! 14-37!

Decomposability and Composability 5! Composability and decomposability are independent and often at odds!» Top down design favours generating modules that fulfill specific requirements! > Unsuitable for composition!» Bottom up design favours general modules that are too general! > When combined generate inefficient systems in size and speed! 14-38!

Decomposability and Composability 6! Composability and decomposability are independent and often at odds!» Top down design favours generating modules that fulfill specific requirements! > Unsuitable for composition!» Bottom up design favours general modules that are too general! > When combined generate inefficient systems in size and speed! Both top down decomposition and bottom up composition are required! 14-39!

Decomposability and Composability 7! Composability and decomposability are independent and often at odds!» Top down design favours generating modules that fulfill specific requirements! > Unsuitable for composition!» Bottom up design favours general modules that are too general! > When combined generate inefficient systems in size and speed! Both top down decomposition and bottom up composition are required!» Trick is to know when and how to best use both methods! 14-40!

Understandability! Understandable!» Minimize need to understand module context! 14-41!

Understandability 2! Understandable!» Minimize need to understand module context! > Know or examine as few other modules as possible! 14-42!

Understandability 3! Understandable!» Minimize need to understand module context! > Know or examine as few other modules as possible! > Very important for maintenance! 14-43!

Continuity! The smaller the change in specification, the fewer the number of modules that must be changed (edited) and if possible compiled! 14-44!

Continuity 2! The smaller the change in specification, the fewer the number of modules that must be changed (edited) and if possible compiled!» Example! > Use of symbolic constants need to change value in one place but requires recompilation of every module using the constant! 14-45!

Understandability and Continuity! Related to coupling and cohesion! A module should do one thing well 14-46!

Modular Protection! Confine abnormal run time errors to one or a very few modules! 14-47!

Modular Protection 2! Confine abnormal run time errors to one or a very few modules! Avoid propagation of error conditions to neighbouring modules! 14-48!

Modular Protection 3! Confine abnormal run time errors to one or a very few modules! Avoid propagation of error conditions to neighbouring modules!» Example! > Validate input before propagating it to other modules! 14-49!

Modular Protection 4! Confine abnormal run time errors to one or a very few modules! Avoid propagation of error conditions to neighbouring modules!» Example! > Validate input before propagating it to other modules! Exceptions in languages like C++ and Java can be used in an undisciplined manner leading to violations of protection! 14-50!

Modular Protection 5! Confine abnormal run time errors to one or a very few modules! Avoid propagation of error conditions to neighbouring modules!» Example! > Validate input before propagating it to other modules! Exceptions in languages like C++ and Java can be used in an undisciplined manner leading to violations of protection!» Exceptions raised in one part of the system should not be handled by a remote part of the system! 14-51!

Design Rules to Ensure Modularity! We have seen criteria for modular software development! 14-52!

Design Rules to Ensure Modularity 2! We have seen criteria for modular software development! From them we can deduce the following rules that can help establish the properties we want in our designs! 14-53!

Design Rules to Ensure Modularity 3! We have seen criteria for modular software development! From them we can deduce the following rules that can help establish the properties we want in our designs!» Direct Mapping rule! 14-54!

Design Rules to Ensure Modularity 4! We have seen criteria for modular software development! From them we can deduce the following rules that can help establish the properties we want in our designs!» Direct Mapping rule!» Few interfaces rule! 14-55!

Design Rules to Ensure Modularity 5! We have seen criteria for modular software development! From them we can deduce the following rules that can help establish the properties we want in our designs!» Direct Mapping rule!» Few interfaces rule!» Small interfaces rule! 14-56!

Design Rules to Ensure Modularity 6! We have seen criteria for modular software development! From them we can deduce the following rules that can help establish the properties we want in our designs!» Direct Mapping rule!» Few interfaces rule!» Small interfaces rule!» Explicit interfaces rule! 14-57!

Design Rules to Ensure Modularity 7! We have seen criteria for modular software development! From them we can deduce the following rules that can help establish the properties we want in our designs!» Direct Mapping rule!» Few interfaces rule!» Small interfaces rule!» Explicit interfaces rule!» Information Hiding rule! 14-58!

Direct Mapping Rule! Correspondence The structure used in implementing a software system should remain compatible with the structure used in modeling the system 14-59!

Direct Mapping Rule 2! Correspondence The structure used in implementing a software system should remain compatible with the structure used in modeling the system Software design involves addressing needs in a problem domain! 14-60!

Direct Mapping Rule 3! Correspondence The structure used in implementing a software system should remain compatible with the structure used in modeling the system Software design involves addressing needs in a problem domain! Have to understand the problem AND its domain, then formulate a solution! 14-61!

Direct Mapping Rule 4! Correspondence The structure used in implementing a software system should remain compatible with the structure used in modeling the system Software design involves addressing needs in a problem domain! Have to understand the problem AND its domain, then formulate a solution! Model our solution in some notation (we use BON)! 14-62!

Direct Mapping Rule 5! Correspondence The structure used in implementing a software system should remain compatible with the structure used in modeling the system Software design involves addressing needs in a problem domain! Have to understand the problem AND its domain, then formulate a solution! Model our solution in some notation (we use BON)! Need a clear mapping from the proposed solution (in BON) to program source text! 14-63!

Direct Mapping Rule 7! Correspondence The structure used in implementing a software system should remain compatible with the structure used in modeling the system Software design involves addressing needs in a problem domain! Have to understand the problem AND its domain, then formulate a solution! Model our solution in some notation (we use BON)! Need a clear mapping from the proposed solution (in BON) to program source text! Arises from continuity and decomposability! 14-64!

Few Interfaces Rule! Every module should communicate with as few others as possible 14-65!

Few Interfaces Rule 2! Every module should communicate with as few others as possible Restrict the number of communication channels between modules! 14-66!

Few Interfaces Rule 3! Every module should communicate with as few others as possible Restrict the number of communication channels between modules! Arises from protection, continuity, composability, decomposability and understandability! 14-67!

Few Interfaces Rule 4! Every module should communicate with as few others as possible Restrict the number of communication channels between modules! Arises from protection, continuity, composability, decomposability and understandability! Hub Composite Ring 14-68!

Small Interfaces Rule! If two modules communicate, they should exchange as little information as possible! 14-69!

Small Interfaces Rule 2! If two modules communicate, they should exchange as little information as possible Also known as weak coupling! 14-70!

Small Interfaces Rule 3! If two modules communicate, they should exchange as little information as possible Also known as weak coupling! Relates to the size of connections rather than their number! 14-71!

Small Interfaces Rule 4! Historical bad idea: Fortran COMMON block!» COMMON block1 A[75], B[25]!» COMMON block1 C[50], D[50]! > View memory in two different ways!! block1 block2 14-72!

Small Interfaces Rule 5! Local variables via Algol-60 block structure! var i Access all variables in outer block i := i + 5 14-73!

Explicit Interfaces Rule! Whenever two modules A and B communicate, this must be obvious from the text of A or B or both 14-74!

Explicit Interfaces Rule 2!! Whenever two modules A and B communicate, this must be obvious from the text of A or B or both Conversation is limited to a few participants and only a few words! 14-75!

Explicit Interfaces Rule 3!! Whenever two modules A and B communicate, this must be obvious from the text of A or B or both Conversation is limited to a few participants and only a few words! Conversations are loud and public! 14-76!

Explicit Interfaces Rule 4!! Whenever two modules A and B communicate, this must be obvious from the text of A or B or both Conversation is limited to a few participants and only a few words! Conversations are loud and public! Really important with respect to understandability! 14-77!

Explicit Interfaces Rule 5!! Whenever two modules A and B communicate, this must be obvious from the text of A or B or both Conversation is limited to a few participants and only a few words! Conversations are loud and public! Really important with respect to understandability! Worry about procedure parameters as well as shared data! 14-78!

Information Hiding Rule (Parnas 72)! The designer of every module must select a subset of properties as the official information about the module, to be made available to client modules 14-79!

Information Hiding Rule (Parnas 72) 2! The designer of every module must select a subset of properties as the official information about the module, to be made available to client modules Only some, but not all of the module's properties are public; the rest are secret! 14-80!

Information Hiding Rule (Parnas 72) 3! The designer of every module must select a subset of properties as the official information about the module, to be made available to client modules Only some, but not all of the module's properties are public; the rest are secret! Public interface! Public Private & Secret 14-81!

Software Construction Principles! Linguistic Modular Units Principle!» Modules must correspond to syntactic language units! 14-82!

Software Construction Principles 2! Linguistic Modular Units Principle!» Modules must correspond to syntactic language units! > Example: in C can include files that begin or end with a partial if then else statement! 14-83!

Software Construction Principles 3! Linguistic Modular Units Principle!» Modules must correspond to syntactic language units! > Example: in C can include files that begin or end with a partial if then else statement! Self-Documenting Principle!» Module designers should make all information about the module part of the module itself! 14-84!

Software Construction Principles 4! Linguistic Modular Units Principle!» Modules must correspond to syntactic language units! > Example: in C can include files that begin or end with a partial if then else statement! Self-Documenting Principle!» Module designers should make all information about the module part of the module itself! > Ideally all program text, diagrams, mathematics and explanations are in one file! 14-85!

Software Construction Principles 5! Uniform Access Principle!» All module services should be available through a uniform notation, which does not betray whether they are implemented through storage or computation! 14-86!

Software Construction Principles 6! Uniform Access Principle!» All module services should be available through a uniform notation, which does not betray whether they are implemented through storage or computation!» Allow implementer to make space-time tradeoffs! 14-87!

Software Construction Principles 7! Uniform Access Principle!» All module services should be available through a uniform notation, which does not betray whether they are implemented through storage or computation!» Allow implementer to make space-time tradeoffs! Single Choice Principle!» Whenever a system must support a set of alternatives, one and only one module in the system should know their exhaustive list! 14-88!

Software Construction Principles 8! In real projects A module needs to be both open and closed! 14-89!

Software Construction Principles 9! In real projects A module needs to be both open and closed! Open-Closed Principle!» Open! > Available for extension add new features! 14-90!

Software Construction Principles 10! Open-Closed Principle!» Open! > Available for extension add new features!» Closed! In real projects A module needs to be both open and closed! > Available for client use stable in spite of extensions! 14-91!

Software Construction Principles 11! Open-Closed Principle!» Open! > Available for extension add new features!» Closed! In real projects A module needs to be both open and closed! > Available for client use stable in spite of extensions! We are never done with extensions! 14-92!

Software Construction Principles 12! Open-Closed Principle!» Open! > Available for extension add new features!» Closed! In real projects A module needs to be both open and closed! > Available for client use stable in spite of extensions! We are never done with extensions! We must make modules available to others! 14-93!

Software Construction Principles 13! In real projects A module needs to be both open and closed! Non OO languages!» Close when stability is reached, reopen when necessary! 14-94!

Software Construction Principles 14! In real projects A module needs to be both open and closed! Non OO languages!» Close when stability is reached, reopen when necessary!» But need to reopen all the clients as well! 14-95!

Software Construction Principles 13! In real projects A module needs to be both open and closed! Non OO languages!» Close when stability is reached, reopen when necessary!» But need to reopen all the clients too!» Inheritance offers a solution to this problem! 14-96!

Software Construction Principles 14! In real projects A module needs to be both open and closed! Non OO languages!» Close when stability is reached, reopen when necessary!» But need to reopen all the clients too!» Inheritance offers a solution to this problem! > But only with multiple inheritance! 14-97!