Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

Software Engineering

Fundamentals
CSC-2073
Lecture No. 30
Dr. Muhammad Adeel
Department of Computer Science
National Textile University

dr.muhammad.adeel.ntu@gmail.com
Last Lecture Review

 Pipes & Filters Architecture

 Pipes & Filters Architecture - Pros & Cons

 Layered Architecture

 Layered Architecture - Pros & Cons

2 Software Engineering - CSC2073


Agenda – What will you Learn Today?

Software Design Software Design


Principles

3 Software Engineering - CSC2073


Software Design

4 Software Engineering - CSC2073


What is Software Design?

 “The process of defining the architecture,


components, interfaces, and other
characteristics of a system or component”

5 Software Engineering - CSC2073


Design Activities

 Hierarchical decomposition of the system into


subsystems
 Determine components and assign to
subsystems
 Determine relationships between components
 Define communication between components
architecture

6 Software Engineering - CSC2073


Design Objectives/Properties

1) Correctness:
 The design of a system is correct if the system
built precisely according to the design satisfies
the requirements of that system
2) Verifiability:
 Design should be verified for correctness
 Verifiability is concerned with how easily the
correctness of the design can be checked
3) Completeness:
 All the different components of the design should
be verified
7 Software Engineering - CSC2073
Design Objectives/Properties

4) Traceability:
 Entire design element be traceable to the
requirements

5) Efficiency:
 Proper use of scarce resources by the system

6) Simplicity:
 The most important quality criteria for software
systems
8 Software Engineering - CSC2073
Software Design Principles

9 Software Engineering - CSC2073


Design Principles

 Design principles are guidelines for


decomposing a system’s required
functionality and behavior into modules

 The principles identify the criteria for


decomposing a system and deciding what
information to provide (and what to conceal)
in the resulting modules

10 Software Engineering - CSC2073


Design Principles

 Six dominant principles:


1. Modularity
2. Interfaces
3. Information hiding
4. Incremental development
5. Abstraction
6. Generality

11 Software Engineering - CSC2073


Design Principles – Modularity

 Modularity is the principle of keeping


separate the various unrelated aspects of a
system, so that each aspect can be studied in
isolation (also called Separation of Concerns)

 To determine how well a design separates


concerns, we use two concepts that measure
module independence: coupling and
cohesion

12 Software Engineering - CSC2073


Design Principles – Modularity

 If the principle is applied well, each resulting


module will have a single purpose and will be
relatively independent of the others
‒ Each module will be easy to understand and
develop
‒ Easier to locate faults (because there are fewer
suspect modules per fault)
‒ Easier to change the system (because a change
to one module affects relatively few other
modules

13 Software Engineering - CSC2073


Coupling - Dependency b/w Modules

Uncoupled – No dependences Loosely coupled - Few dependencies

What do we want?
Low coupling. Why?
 Replaceable
 Enable changes
 Testable - isolate faults
 Understandable
Highly Coupled - Many dependencies

14 Software Engineering - CSC2073


Coupling – Example

class Complex
{
public double real;
public double imaginary;

public Complex(double real, double imaginary);


public double getReal();
public double getImaginary();
public void Display();
} // End of class

15 Software Engineering - CSC2073


Coupling – Example

Complex Add (Complex a, Complex b)


{
Complex temp;
temp.real = a. real + b.real;
temp.imaginary = a.imaginary + b.imaginary;
return temp;
}
Complex Subtract (Complex a, Complex b)
{
Complex temp;
temp.real = a. real - b.real;
temp.imaginary = a.imaginary - b.imaginary;
return temp;
}
16 Software Engineering - CSC2073
Coupling – Example

class Complex
{
private double real;
private double imaginary;

public Complex(double real, double imaginary);


public double getReal();
public double getImaginary();
public void Display();
} // End of class

17 Software Engineering - CSC2073


Coupling – Example

Complex Add (Complex a, Complex b)


{
Complex temp;
temp.real = a. real + b.real;
temp.imaginary = a.imaginary + b.imaginary;
return temp;
}

18 Software Engineering - CSC2073


Coupling – Example

Complex Add (Complex a, Complex b)


{
Complex temp;
temp.real = a. getReal() + b.getReal();
temp.imaginary = a.getImag() + b.getImag();
return temp;
}

19 Software Engineering - CSC2073


Cohesion - Relation b/w Internal Parts
of the Module

Low Cohesion - The parts e.g. functions Medium Cohesion - Some logically
have less or nothing in common related function. e.g. IO related functions

What do we want?
High cohesion. Why?
 More understandable
 Easier to maintain
High Cohesion - Does only what it is
designed for?

20 Software Engineering - CSC2073


Cohesion – Example

class Order
{
private int OredrID;
private string CustomerName;
private Date OrderDate;
private float TotalPrice;
private int CustomerID;
private int CustomerPhone;

21 Software Engineering - CSC2073


Cohesion – Example

public int getOrderID();


public Date getOrderDate();
public float getTotalPrice();
public int getCustometId();
public string getCustomerName();
public string getCustometAddress();
public int getCustometPhone();
public void setOrderID(int id);
public void setOrderDate(Date date);
public void setTotalPrice(float price);
public void setCustometId(int cstmrID);
public void setCustomerName(string cName);
public void setCustometAddress(string address);
} // End of Order class

22 Software Engineering - CSC2073


Cohesion – Example

class Order
{
private int OrderId;
private Date OrderDate;
private float TotalPrice;
public int getOrderID();

public Date getOrderDate();


public float getTotalPrice();
public void setOrderID(int ordrID);
public void setOrderDate(Date date);
public void setTotalPrice(float price);
} // End of Order class

23 Software Engineering - CSC2073


Cohesion – Example

class Customer
{
private int CustomerID;
private string CustomerName;
private int CustomerPhone;

public int getCustometID();


public string getCustomerName();
public string getCustometAddress();
public void setCustometId(int cstmrID);
public void setCustomerName(string cName);
public void setCustomerAddress(string
address);
} // End of Customer class

24 Software Engineering - CSC2073


Design Principles – Interfaces

 An interface defines what services the


software unit provides to the rest of the
system, and how other units can access
those services
 An interface must also define what the unit
requires, in terms of services or assumptions,
for it to work correctly
Interface Name
+ Behavior1()
+ Behavior2()

25 Software Engineering - CSC2073


Design Principles – Interfaces

 A software unit may have several interfaces that


make different demands on its environment or that
offer different levels of service
Module
Data
_________________ Operation 3
_________________ _________________
_________________ Interface A
_________________
_________________ _________________ Operation 1 ()
_________________ Operation 2 ()
Operation 1
_________________
_________________ Operation 4
_________________
_________________ Interface B
_________________
_________________ _________________ Operation 3 ()
_________________ Operation 4 ()
Operation 2
_________________
_________________
_________________
_________________

26 Software Engineering - CSC2073


Design Principles – Interfaces

 A software unit may have several interfaces that


make different demands on its environment or that
offer different levels of service
Module
Data
_________________ Operation 3
_________________ _________________
_________________ Interface A
_________________
_________________ _________________ Operation 1 ()
_________________ Operation 2 ()
Operation 1
_________________
_________________ Operation 4
_________________
_________________ Interface B
_________________
_________________ _________________ Operation 3 ()
_________________ Operation 4 ()
Operation 2
_________________
_________________
_________________
_________________

27 Software Engineering - CSC2073


Design Principles – Interfaces

 The specification of a software unit’s interface


describes the externally visible properties of
the software unit
 An interface specification should
communicate to other system developers
everything that they need to know to use our
software unit correctly
 A software unit’s interface describes what the
unit requires of its environment, as well as
what it provides to its environment
28 Software Engineering - CSC2073
Recap

 Software Design
– Design Activities
– Design Objectives/Properties
 Software Design Principles
– Modularity
o Coupling
o Cohesion
– Interfaces

29 Software Engineering - CSC2073


Questions

30 Software Engineering - CSC2073

You might also like