SOFTWARE DESIGN ATTRIBUTES AND
GOALS
Software Design Patterns
FAKHRELDIN ALI
[Link]@[Link]
OBJECTIVES
To learn the software design attributes
To learn the software design goals
2
TOPICS COVERED
Design process characteristics
Software design attributes
Software design goals
3
DESIGN PROCESS CHARACTERISTICS
Design is a problem-solving process
Different from most scientific problem-solving such as finding the distance between
two points.
It is a wicked problem: a problem with no definitive solution
Many possible solutions.
May not have a single preferred solution.
4
DESIGN ATTRIBUTES
Abstraction
Simplicity
Decomposition & Modularity
Coupling & Cohesion
Encapsulation & Information hiding
5
ABSTRACTION
Identify the important parts and ignore the unnecessary details
“The process of forgetting information so that things that are different can be
treated as if they were the same” -Liskov & Guttag
6
ABSTRACTION
Abstraction in real life
• Your car is a great example of abstraction. You can start the car by turning the
key or pressing the start button. You don't need to know how the engine starts,
what components your car has. The internal implementation and complex logic
of the car is completely hidden from the user.
• We can heat our food in the microwave. We press a few buttons to set the
timer and the type of food. Finally, we eat a warm and delicious meal. The
internal details of the microwave are hidden from us. We have accessed the
functionality in a very simple way.
7
ABSTRACTION
Abstraction in Java:
In Java, abstraction is achieved through abstract classes and interfaces. Abstract
classes serve as blueprints for other classes and can contain both abstract
(methods without implementation) and concrete methods. By using the
`abstract` keyword, developers can create abstract classes, allowing for partial
abstraction and method sharing among derived classes.
Interfaces, on the other hand, provide a way to achieve full abstraction. An
interface defines a contract for methods without any implementation. Any class
implementing an interface must provide concrete implementations for all the
methods declared in the interface. This feature enables multiple classes to adhere
to a specific interface, promoting consistency and interoperability.
8
SIMPLICITY
Function or method complexity
Mccabe’s Cyclomatic Complexity
Cyclomatic complexity is a quantitative measure of a computer program's
complexity used in computer science. In essence, it reflects the number of linearly
independent paths through a program's source code.
Structural complexity
Henry-Kafura information flow complexity
9
SIMPLICITY
Use of Cyclomatic Complexity
• Determining the independent path executions thus proven to be very helpful for
Developers and Testers.
• It can make sure that every path has been tested at least once.
• Thus help to focus more on uncovered paths.
• Code coverage can be improved.
• Risks associated with the program can be evaluated.
• These metrics being used earlier in the program help in reducing the risks.
10
SIMPLICITY
Advantages of Cyclomatic Complexity
• It can be used as a quality metric, given the relative complexity of various designs.
• It is able to compute faster than Halstead’s metrics.
• It is used to measure the minimum effort and best areas of concentration for testing.
• It is able to guide the testing process.
• It is easy to apply.
Disadvantages of Cyclomatic Complexity
• It is the measure of the program’s control complexity and not the data complexity.
• In this, nested conditional structures are harder to understand than non-nested
structures.
• In the case of simple comparisons and decision structures, it may give a misleading 11
figure.
MODULARITY
Modularity
Easy to replace
Easy to reuse
Help comprehension and maintenance
Help a team to design
Decomposition
Developing the design by successively refining levels of details
12
COUPLING & COHESION
Coupling: Interactions among modules
Functions calls
Share of global variables
Message passing
Use of abstract data types
Inheritance
Cohesion: The strength of association within a module
13
COUPLING & COHESION
14
COUPLING & COHESION
15
COUPLING & COHESION
16
ENCAPSULATION & INFORMATION HIDING
Grouping the elements and internal details of an
abstraction and making those details inaccessible
Desirable property of module design
Used in Object-Oriented programming
17
ENCAPSULATION & INFORMATION HIDING
Advantages of Information Hiding and Encapsulation:
• Simplicity & Clarity: By hiding complex details, code becomes easier to
understand and use.
• Lower Complexity: Encapsulation organizes code into manageable chunks,
making it easier to work with and maintain.
• Better Understanding: By separating what’s important (the interface) from how
it’s done (the implementation), these principles make code easier to
comprehend and work with.
18
ENCAPSULATION & INFORMATION HIDING
19
GOALS OF SOFTWARE DESIGN
Correctness
Robustness
Flexibility
Reusability
Efficiency
Reliability
Usability
20
GOALS OF SOFTWARE DESIGN: CORRECTNESS
Software design must satisfy the requirements for the application
Sufficiency
Completeness
21
GOALS OF SOFTWARE DESIGN: ROBUSTNESS
A design or implementation is robust if it is able to handle miscellaneous and
unusual conditions such as bad data, user error, programmer error, and
environmental conditions
22
GOALS OF SOFTWARE DESIGN: FLEXIBILITY
Requirements of an application can change in many ways
Separation of interface and implementation
Aspects of flexibility
Obtaining more or less of what’s already present,
e.g. handle more kinds of account
Adding new functionality
Add withdraw to existing deposit function
Change functionality
Allow withdrawal to create an overdraft
23
GOALS OF SOFTWARE DESIGN: REUSABILITY
The trend in software is to reuse parts among applications
Example, JAVA API --- a large, extensive body of widely reused classes
Types of reusability
Object code (or equivalent)
Example: sharing dll’s between word processor and spreadsheet
Classes – in source code form
Example: Customer class used by several applications
Thus, we write generic code whenever possible
Assemblies of Related Classes
Example: the [Link] package
Patterns of Class Assemblies
Design patterns
24
GOALS OF SOFTWARE DESIGN: EFFICIENCY
Efficiency refers to the use of available machine cycles and memory
Create designs and implementations that are as fast as required, and which make
use of no more than available memory
Efficiency often contradicts with other design goal
25
GOALS OF SOFTWARE DESIGN: RELIABILITY
An application is reliable if it is relatively defect free
Metric for reliability
Average time between failures
Clean designs make it easier for developers to produce error-free applications
26
GOALS OF SOFTWARE DESIGN: USABILITY
An application has high usability if users find it easy to use
Usability is attained through human-interface design
27
A CHECKLIST FOR CHECKING SOME OF THE
GOALS OF SOFTWARE DESIGN
How can we tell from the code that all required functionality has
been handled? (correctness)
If the user makes a mistake, does the system crash or perform
unpredictably (robustness)
Is the system hard to modify, add or remove parts? (flexibility)
Does the system execute fast enough? (speed efficiency)
Does the system satisfy memory requirements? (space efficiency)
Are the class usable for other applications? (reusability)
28
SUMMARY
Goals of software design
Correctness
Software design attributes: Robustness
Abstraction Flexibility
Simplicity Reusability
Decomposition & Modularity Efficiency
Coupling & Cohesion Reliability
Encapsulation & Information hiding Usability
29