Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Quality of a Class Abstraction: Coupling & Cohesion Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Software Design Deriving a solution which satisfies software Speficitaion.
Software Engineering Software Design Slide 1 Software Engineering Software Design.
Software Design Hoang Huu Hanh, Hue University hanh-at-hueuni.edu.vn.
Lecture 9 Improving Software Design CSC301-Winter 2011 – University of Toronto – Department of Computer Science Hesam C. Esfahani
What is Software Design?  Introduction  Software design consists of two components, modular design and packaging.  Modular design is the decomposition.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Issues Derived from Dr. Fawcett’s Slides Phil Pratt-Szeliga Fall 2009.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
MADALINA CROITORU Software Engineering week 4 Madalina Croitoru IUT Montpellier.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
An Introduction to Software Architecture
CSE 303 – Software Design and Architecture
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
Design (1) Design involves decisions on how to deliver the agreed functionality to the users. Design involves development of a clear, unambiguous and consistent.
Week 4 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
1 Software Design Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13, 5 th edition and Ch. 10, 6 th edition.
Computer Concepts 2014 Chapter 12 Computer Programming.
Sommerville, Mejia-Alvarez, 2009Software Engineering, Slide 1 Software Design u Deriving a solution which satisfies software requirements.
Software Design Deriving a solution which satisfies software requirements.
Software Design Process A solution to satisfy the requirements ◦ Design process and methods ◦ Design strategies including object-oriented design and functional.
1 Software Design Overview Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13.
Cohesion and Coupling CS 4311
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Software Design Design is the process of applying various techniques and principles for the purpose of defining a device, a process,, or a system in sufficient.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Introduction to Classes and Objects. Real Life When a design engineer needs an electrical motor he doesn’t need to worry about –How a foundry will cast.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Dr D. Greer, Queens University Belfast )Chapter Six 1 Software Engineering Chapter Six Software Design Quality Learning Outcomes.
© 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.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Week 6: Software Design HNDIT Software Engineering Software Design Learning Outcomes  Understand the activities involved in the Design process.
Object-Oriented Design Concepts University of Sunderland.
©Ian Sommerville 1995 Software DesignSlide 1 Software Design u Deriving a solution which satisfies software requirements.
Rohini Sharma Roll No. RA1809A01 Regd. No M.Tech.(CSE) Part Time 3 rd Semester.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Slide 7B.31 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Chapter 10 Software quality. This chapter discusses n Some important properties we want our system to have, specifically correctness and maintainability.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
CSCE 240 – Intro to Software Engineering Lecture 3.
Coupling and Cohesion Schach, S, R. Object-Oriented and Classical Software Engineering. McGraw-Hill, 2002.
Coupling and Cohesion Pfleeger, S., Software Engineering Theory and Practice. Prentice Hall, 2001.
Coupling and Cohesion 1.
which satisfies software requirements
Improving the Design “Can the design be better?”
Software Engineering Lecture #8.
Programming Logic and Design Fourth Edition, Comprehensive
Cohesion and Coupling.
Software Engineering Software Design.
Presentation transcript:

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture 14 – Design Methodology 1 COMP201 - Software Engineering

Software Design In this lecture we shall again be looking at how to derive a software solution which satisfies the software requirements. We shall be examining ways in which architecture designs and individual components can be said to be “good” in practice. 2 COMP201 - Software Engineering

What makes a Good System? We may remark that a good system has the following properties: Useful and usable; Reliable; Flexible; Affordable; Available. During this lecture we will be considering design properties of modules. Question: How do modules allow us to meet some or all of the above goals of a good system? COMP201 - Software Engineering 3

Module Interfaces Firstly let us recall what an interface is. An interface to a module defines some features of the module upon which other parts of the system may rely. It is thus an abstraction of the module. Encapsulation of the module means that users of the module cannot know more about the module than is given by the interface. Any assumptions about interfaces should be documented in the interface. This means that any changes to the internals of a module not causing a change to the interface should not necessitate a change to other parts of the system. COMP201 - Software Engineering 4

Interfaces – an Example COMP201 - Software Engineering 5 // A C++ Vector class to perform mathematical calculations // All Vector arguments should be normalized class Vector { public: Vector(float x, float y, float z); ~Vector(); float dotProduct(Vector inVector); Vector crossProduct(Vector inVector); void setVector(float x, float y, float z); private: void normalize(); float x_value; float y_value; float z_value; }; Private interface Public interface

Interfaces – an Example COMP201 - Software Engineering 6 On the previous slide, do you know how to compute the cross product of two vectors? The point is that due to abstraction, you do not need to know, that information is hidden in the module! We may choose to replace the code for computing the cross product to be faster or more numerically stable for example, but users of the module (or component) should not need to change their code since the interface has not changed.

Five Principles for Good Design From the discussion in the previous lecture, we can derive five principles that should be adhered to: Linguistic modular units; Few interfaces; Small interfaces; Explicit interfaces; Information hiding. 7 COMP201 - Software Engineering

Linguistic Modular Units A programming language (or design language) should support the principle of linguistic modular units: Modules must correspond to linguistic units in the language used EXAMPLE: Java methods and classes COUNTER EXAMPLE: Subroutines in BASIC are called by giving a line number where execution is to proceed from; there is no way of telling, just by looking at a section of code, that it is a subroutine. Assembler, C, C++, private or public data 8 COMP201 - Software Engineering

Few Interfaces This principle states that the overall number of communication channels between modules should be as small as possible: Every module should communicate with as few others as possible. So, in the system with n modules, there may be a minimum of n-1 and a maximum of links; your system should stay closer to the minimum. 9 COMP201 - Software Engineering

Few Interfaces 10 COMP201 - Software Engineering

Facade structure COMP201 - Software Engineering 11 Public interface Package

Small Interfaces (Loose Coupling) Loose coupling implies that : If any two modules communicate, they should exchange as little information as possible. An interface to a module defines the features on which a client may rely and the rest of the system can only use the module as permitted by the interface. COUNTER EXAMPLE. Declaring all instance variables as public! 12 COMP201 - Software Engineering

Coupling Coupling is a measure of the strength of the inter- connections between system components. Loose coupling means component changes are unlikely to affect other components. Shared variables or control information exchange lead to tight coupling (usually bad). Loose coupling can be achieved by state decentralization (as in objects) and component communication via parameters or message passing. 13 COMP201 - Software Engineering

Tight Coupling 14 COMP201 - Software Engineering

Loose Coupling 15 COMP201 - Software Engineering

Object-oriented systems are loosely coupled because there is no shared state and objects communicate using message passing. However, an object class is coupled to its super- classes. Changes made to the attributes or operations in a super-class propagate to all sub-classes. Coupling and Inheritance 16 COMP201 - Software Engineering

Reusability A major obstacle to the production of cheap quality software is the intractability of the reusability issue. Why isn’t writing software more like producing hardware? Why do we start from scratch every time, coding similar problems time after time after time? Obstacles: Economic Organizational Psychological 17 COMP201 - Software Engineering

Stepwise Refinement The simplest realistic design method, widely used in practice. Not appropriate for large-scale, distributed systems: mainly applicable to the design of methods. Basic idea is: Start with a high-level spec of what a method is to achieve; Break this down into a small number of problems (usually no more than 10) For each of these problems do the same; Repeat until the sub-problems may be solved immediately. 18 COMP201 - Software Engineering

Explicit Interfaces If two modules must communicate, they should do it so that we can see it: If modules A and B communicate, this must be obvious from the documentation of A or B or both. Why? If we change a module, we need to see what other modules may be affected by these changes. A traceability matrix can be used for this purpose. 19 COMP201 - Software Engineering

Information Hiding (Encapsulation) This principle states: All information about a module, (and particularly how the module does what it does) should be private to the module unless it is specifically declared otherwise. Thus each module should have an interface, which is how the world sees it anything beyond that interface should be hidden. There is a limit to how much humans can understand at any one time. The default Java rule: Make everything private 20 COMP201 - Software Engineering

Cohesion Cohesion - A measure of how well a component “fits together” A component should implement a single logical entity or function. Cohesion is a desirable design component attribute as when a change has to be made, it is localized in a single cohesive component. Various levels of cohesion have been identified. 21 COMP201 - Software Engineering

Cohesion Levels Coincidental cohesion (weak) Parts of a component are simply bundled together. Logical association (weak) Components which perform similar functions are grouped. Temporal cohesion (weak) Components which are activated at the same time are grouped. 22 COMP201 - Software Engineering

Cohesion Levels Communicational cohesion (medium) All the elements of a component operate on the same input or produce the same output. Sequential cohesion (medium) The output for one part of a component is the input to another part. Functional cohesion (strong) Each part of a component is necessary for the execution of a single function. Object cohesion (strong) Each operation provides functionality which allows object attributes to be modified or inspected. 23 COMP201 - Software Engineering

Cohesion as a Design Attribute The concept of cohesion is not well-defined and is often difficult to classify. Inheriting attributes from super-classes weakens cohesion. To understand a component, the super-classes as well as the component class must be examined. Object class browsers assist with this process. 24 COMP201 - Software Engineering

Cohesion versus Encapsulation Cohesion is a measure of abstraction that means developers do not need concern themselves with the internal working of a module. Encapsulation means that developers are unable to use hidden information within a module, ensuring that subtle errors cannot be introduced when using connected modules. This is a subtle but important difference between the two concepts. COMP201 - Software Engineering 25

An Example Imagine a class that stores a two-dimensional point and provides get/set methods in both Cartesian and polar coordinates. Does the class store the point in both sets of coordinates and keep them consistent, or convert the values each time we use the methods? The point is that the user of the class doesn’t need to know these details! This is the main idea of cohesion and encapsulation (or information hiding). If this was a Java class, the get/set methods would be public and the data would be declared private. COMP201 - Software Engineering 26

High Cohesion, Low Coupling Modules If a module has high cohesion, low coupling and a well defined interface, then it may be feasible to reuse that module in other systems, i.e., it may be a pluggable module. This will also depend upon the architecture in which the module was developed, remember the example of the Ariane 5 space launcher from the last lecture? Architectural decisions are usually important to the entire design of the module and thus should be taken early. For example, perhaps the module would be made less efficient but more general since we may wish to reuse the module later.. COMP201 - Software Engineering 27

Again..what makes a Good System? We said that a good system has the following properties: Useful and usable; Reliable; (low coupling) Flexible; (low coupling, high cohesion) Affordable; (software reuse) Available. (decreased development time through reuse) Question: Can we now answer why properly designed modules allow us to meet some or all of the above goals of a good system? COMP201 - Software Engineering 28

Lecture Key Points We have seen the definition of coupling, cohesion and interfaces to modules and how they can inform us about the reusability of a component Decisions about modules and their interfaces are important design considerations that should be made early in the design phase Object-oriented development often encourages good modular design COMP201 - Software Engineering 29