From Module To Objects

Similar documents
Testing, Module To Object, Reusability

CHAPTER 1 Fundamentals of Distributed System. Issues in designing Distributed System

Object-Oriented Concepts and Design Principles

UNIT II Requirements Analysis and Specification & Software Design

Elementary Concepts of Object Class

CHAPTER 5 GENERAL OOP CONCEPTS

Part 7 - Object Oriented Concepts Classes, Objects, Properties and Methods

Object-Oriented Design

Chapter 5 Object-Oriented Programming

Introduction to Software Engineering p. 1 The Scope of Software Engineering p. 3 Historical Aspects p. 4 Economic Aspects p. 7 Maintenance Aspects p.

Chapter 8: Class and Method Design

CHAPTER 4 HEURISTICS BASED ON OBJECT ORIENTED METRICS

Software Design. Software design is a blueprint or a plan for a computerbased solution for system

Classwide Programming 1

CSC207H: Software Design SOLID. CSC207 Winter 2018

Object-Oriented Programming in C++/Handout 01 Page 1 of 8

Object oriented programming Concepts

What are the characteristics of Object Oriented programming language?

Introduction to Object-Oriented Programming

OBJECT ORIENTED PROGRAMMING

1. Write two major differences between Object-oriented programming and procedural programming?

Intro to: Design Principles

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

BASIC CONCEPT OF OOP

Design Principles & Prac4ces

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

CS 307: Software Engineering. Lecture 9: Software Design (Coupling), Modeling Interactions and Behavior

Lethbridge/Laganière 2005 Chapter 9: Architecting and designing software 6

The Object Oriented Paradigm

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

Software Metrics and Design Principles. What is Design?

AOSA - Betriebssystemkomponenten und der Aspektmoderatoransatz

Design and Information Hiding

Rediscovering. Modularity. Stuttgart JUG November 20 th 2012

What is a Programming Paradigm

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

CSC 330 Object-Oriented Software Design REUSABILITY

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?

Object interconnections

Object-Oriented Design

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

OBJECT ORIENTED SYSTEM DEVELOPMENT Software Development Dynamic System Development Information system solution Steps in System Development Analysis

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

OOAD - OBJECT MODEL. The concepts of objects and classes are intrinsically linked with each other and form the foundation of object oriented paradigm.

CS313D: ADVANCED PROGRAMMING LANGUAGE

Chapter No. 2 Class modeling CO:-Sketch Class,object models using fundamental relationships Contents 2.1 Object and Class Concepts (12M) Objects,


CS313D: ADVANCED PROGRAMMING LANGUAGE

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

Darshan Institute of Engineering & Technology for Diploma Studies

Lecture 1. Abstraction

System Design. Design: HOW to implement a system

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Design Concepts and Principles

CS 307: Software Engineering. Lecture 10: Software Design and Architecture

Element: Relations: Topology: no constraints.

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

REVIEW OF THE BASIC CHARACTERISTICS OF OBJECT ORIENTATION

Software Engineering

System Design. Design Issues. System Design. System Design. Design: HOW to implement a system. Strategic vs. Local Design Decisions.

UNIT III. Software Design

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Design: HOW to implement a system

Session 4b: Review of Program Quality

SOFTWARE ENGINEERING. Lecture 6. By: Latifa ALrashed. Networks and Communication Department

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

CSCI 253. Outline. Background. George Blankenship 1

THE OBJECT-ORIENTED DESIGN PROCESS AND DESIGN AXIOMS (CH -9)

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

Inheritance, Polymorphism and the Object Memory Model

Component-Level Design

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

1. Software Systems Complexity, OO Paradigm, UML

Topics in Object-Oriented Design Patterns

Inheritance (Chapter 7)

Software Engineering Principles

Object- Oriented Design with UML and Java Part I: Fundamentals

CMPS 115 Winter 04. Class #10 (2004/02/05) Changes/Review Programming Paradigms Principles of OOD <break> Design Patterns

Object-Oriented and Classical Software Engineering THE TOOLS OF THE TRADE 9/22/2017. CHAPTER 5 Slide 5.2. Stephen R. Schach. Overview Slide 5.

Java Basics. Object Orientated Programming in Java. Benjamin Kenwright

G Programming Languages - Fall 2012

A Hierarchical Model for Object- Oriented Design Quality Assessment

CS111: PROGRAMMING LANGUAGE II

Introduction to System Design

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

Introduction to Object-Oriented Programming

Java Object Oriented Design. CSC207 Fall 2014

Address spaces and memory management

User Defined Types. Babes-Bolyai University Lecture 06. Lect Phd. Arthur Molnar. User defined types. Python scope and namespace

Data Abstraction. Hwansoo Han

Sri Vidya College of Engineering & Technology

Analysis of Cohesion and Coupling Metrics for Object Oriented System

The major elements of the object-oriented model

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Crash Course in Modernization. A whitepaper from mrc

CSE 401/M501 Compilers

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

Object Oriented Programming

Transcription:

From Module To Objects It is very difficult to maintain a large monolithic block of code The solution is to divide the code into smaller pieces, called modules What is a Module? A small and manageable piece of code 1 From Module To Objects A module is a lexically contiguous sequence of program statement, bounded by boundary elements, having an aggregate identifier [Yourdon and Constantine, 1979] Examples: Begin end pairs in Pascal or ADA {.} pairs in C, C++, or JAVA 2 1

From Module To Objects Distinction between ACTION, LOGIC, and CONTEXT of a module ACTION What the module does, the behavior LOGIC How the module performs its action CONTEXT The specific usage of that module 3 From Module To Objects In Composite/Structured Design (C/SD) a module should be named after its action not its logic Example: A module that calculates the square root should be called compute square root and not m 4 2

Object-Oriented Paradigm Major Object-Oriented Concepts Reusability High cohesion and low coupling Encapsulation Data and procedural abstraction Inheritance Polymorphism 5 Cohesion Degree of interaction within a module (Good) (Bad) 7 levels of cohesion Information cohesion» Optimal for Object-Oriented paradigm Functional cohesion» Optimal for Structured programming paradigm Communicational cohesion Procedural cohesion Temporal cohesion Logical Cohesion Coincidental cohesion 6 3

Coincidental Cohesion A module that performs multiple, completely unrelated actions has coincidental cohesion Reasons for developing coincidental cohesion Management requires 50 executable statements in a module Module is too big or too small To correct coincidental cohesion: Break the modules into smaller modules that perform one action 7 Coincidental Cohesion Why is it a bad thing? Degrades the maintainability Corrective or Enhancement maintenance Difficult to understand the product due to its complexity Modules are not reusable. Coincidental cohesion is worse than no modularization [Shneiderman & Mayer, 1975] 8 4

Logical Cohesion A module that performs a series of related actions, one of which is selected by the calling module To correct logical cohesion: Break the modules into smaller modules that perform one action 9 Logical Cohesion Why is it a bad thing? Interface is difficult to understand Degrades the maintainability Corrective or Enhancement maintenance Difficult to understand the product due to its complexity Modules are not reusable 10 5

Temporal Cohesion A module that performs a series of actions related in time Example: Perform Initialization Open old master file, new master file, transaction file, and print file, initialize sales region table.. To correct temporal cohesion: Break the modules into smaller modules that perform one action 11 Temporal Cohesion Why is it a bad thing? Degrades the maintainability Corrective or Enhancement maintenance Difficult to understand the product due to its complexity Modules are not reusable 12 6

Procedural Cohesion A module that performs a series of actions related by the sequence of steps to be followed Example: Read part number from database and update repair record in maintenance file Better than temporal cohesion Actions are related procedurally 13 Procedural Cohesion To correct procedural cohesion: Break the modules into smaller modules that perform one action Why is it a bad thing? Degrades the maintainability Corrective or Enhancement maintenance Difficult to understand the product due to its complexity Modules are not reusable 14 7

Communicational Cohesion A module that performs a series of actions related by the sequence of steps to be followed and all the actions are on the same data Example: Update record in database and write it to the audit trail Calculate new trajectory and send it to the printer Better than procedural cohesion Actions are more closely connected 15 Communicational Cohesion To correct Communicational cohesion: Break the modules into smaller modules that perform one action Why is it a bad thing? Degrades the maintainability Corrective or Enhancement maintenance Difficult to understand the product due to its complexity Modules are not reusable 16 8

Functional Cohesion A Module that performs exactly one action Examples Calculate sales commission Get temperature of furnace 17 Functional Cohesion Why is it a GOOD thing? Since it only performs one action it is easy to understand Easily maintained Faults can be isolated easily It can be reused A properly designed, documented, and tested module is a valuable asset 18 9

Information Cohesion A module that performs a number of actions, each with its own entry point, with independent code for each action Major difference between logical and informational cohesion Various actions in logical cohesion are intertwined Each actions in information cohesion are completely independent 19 Coupling Degree of interaction between two modules (Good) (Bad) 5 levels of coupling Data Coupling Stamp Coupling Control Coupling Common Coupling Content Coupling 20 10

Content Coupling A module directly references the content of another module Examples Module p modifies a statement in module q Module p refers to local data of module q 21 Content Coupling Why is it a bad thing? Modules are inextricably interlined Inextricable [Webster Dictionary] Forming a maze or tangle from which it is imposable to get free Incapable of being disentangled or untied Difficult to maintain Cannot be reused 22 11

Common Coupling Modules have access to the same global data Why is it a bad thing? Contradicts the structured programming paradigm Modules have side effects that affect their readability Module can be exposed to sensitive data 23 Common Coupling Why is it a bad thing? Difficult to maintain A change in one requires a change in all Difficult to reuse Must reuse all common data 24 12

Control Coupling A module passes an element of control to another module A module directly controls another module Examples Module p calls module q, module q passes not only data but a control that module p has to act on Generally associated with modules with logic cohesion 25 Control Coupling Why is it a bad thing? Modules can not be reused Difficult to understand the structure of modules Difficult to maintain 26 13

Stamp Coupling Module passes a data structure as an argument to another. The calling module operates only on some component of the data structure Examples Calculate withholdings by passing the employee record The called module does not need the employee s home phone number Security reasons are the main concern 27 Stamp Coupling It is justified to pass a data structure to another module if the called module acts on all the data components of the data structure Examples Invert matrix (old matrix, new metric) How to solve this problem? Pass the necessary data to the module 28 14

Stamp Coupling Performance problems? Don Knuth s laws [Knuth, 1974] First law of optimization: Don t! There rarely is a need for optimization of any kind, including for performance reasons Second law of optimization: Not yet! Complete the entire product using appropriate software engineering techniques If optimization really is required, make only necessary changes, carefully documenting what is being changed and why. 29 Data Coupling Modules that pass either data structure or simple arguments Reduces maintenance Well defined interfaces A change to one module is less likely to effect the other 30 15

Important Points If a module is tightly coupled with another module, then a change to one module requires a change in the other module Well designed code! A good design has high cohesion and low coupling 31 Data Encapsulation A module that contains the data structure together with the actions to be performed on that data structure Gathering all aspect of real-world entity together into one unit 32 16

Abstraction Data Encapsulation The act or process of removing or separating [Webster dictionary] Achieving stepwise refinement by suppressing unnecessary details Separating the detail from design 33 Abstract Data Type A data type, together with the actions performed on instances of that type 34 17

Information Hiding Data abstraction and procedural abstraction are examples of Information Hiding concept Data abstraction Hiding the details of the data from other modules Procedural abstraction Hiding the details of the procedures from other modules 35 Information Hiding Modules with their implementation details are hidden It is more accurate to say Detail Hiding versus Information Hiding This way changing the design of the module will not effect any other module JAVA and C++ offer ways to hide these using class specification 36 18

Information Hiding Implementation details of: Invisible to outside queue queue length InitializeJobQueue addjobqueue removejobfromqueue Visible to outside Interface information regarding: initializejobqueue addjobtoqueue removejobfromqueue 37 Objects Object is an instance of a class Class Abstract Data Type that supports Inheritance Contains data and methods as it s members JAVA A dot (.) denotes membership ClassA.attributeB ClassA.methodC() 38 19

Inheritance The idea of extending a data type versus generating a new data type Derived part HumanBeing Parent Incremental part 39 Aggregation Components of a class Personal computer CPU Monitor Printer 40 20

Association Some kind of relationship between two apparently unrelated classes Car Owner Consults mechanic 41 Inheritance, Polymorphism, and Dynamic Binding By defining abstract methods (JAVA) or virtual methods (C++) one can delay the selection of an operation Binding is done Dynamically versus Statically Done at run time versus compile time 42 21

Inheritance, Polymorphism, and Dynamic Binding FileClass Abstract method open() DiskFileClass TapeFileClass DisketteFileClass method open() for disk files method open() for tape files method open() for diskette files 43 Inheritance, Polymorphism, and Dynamic Binding Advantages Can define different methods to handle different types of actions versus writing an IF statement in traditional programming languages The programming language/compiler/os takes care of the decision Binding (act of selecting) is done during RUN time 44 22

Inheritance, Polymorphism, and Dynamic Binding Disadvantage Impossible to determine at compilation time which version of a polymorphic method will be invoked at run time Could have a negative impact on maintenance Need to understand the product CASE Tools can help reduce the complexity by showing the class tree graphically 45 Object-Oriented Paradigm If Object-Oriented paradigm is a better paradigm, why has the structured paradigm had so many successes? Adopted when software engineering was not widely practiced Software was simply written Generating code was the important task for managers 46 23

Object-Oriented Paradigm Object-Oriented paradigm is an old concept. This concept is seen to improve software engineering Well designed objects have high cohesion and low coupling Modeling aspects of one physical entity 47 Object-Oriented Paradigm The implementation details are hidden Easily maintainable Communication is performed via messages sent to an object Objects are independent with well defined interfaces Objects are reusable Reusability is enhanced by the concept of inheritance 48 24