Chapter - 1 AND 2
Chapter - 1 AND 2
The what (is the problem), during RE, of the software under attention is
converted to How (is the problem solved)?
2
Why Should The Software Be
Designed At All?
Because:
We can’t just throw few dozens of programmers to start programming without any
detailed plans.
Design is highly creative stage in software development where the designer plans
3
What is Software Design?
• Software design sits at the technical kernel of SE and is applied regardless of
• Software Design is an iterative and creative process targeting to create solution for the users
requirements.
• Software design is an iterative process through which requirements are translated into a “blueprint”
for constructing the software.
• Design is the only way that we can accurately translate a customer's requirements into a finished software
product or system.
• The difference between several software developed for the same purpose is nothing more that
difference in Quality.
5
Design and Software Qualities ....
For the systems to be reliable, the designers should count on
3. User control and freedom: give freedom to user but until they become dangerous
4. Consistency and standards: if ok &cancel buttons are left & right. must always be so
5. Error prevention: male/female check/combobox is better than textbox where user can enter wrong data
6. Recognition rather than recall ( Minimize the user's memory load by making objects,
actions, and options visible.)
7. Flexibility and efficiency of use
8. Aesthetic and minimalist design
9. Help users recognize, diagnose, and recover from errors
7
10. Help and documentation
Design Strategies
• Before sinking into Design Process detail ,Pick a strategy[aka
Methodology]
8
Complexity of design
• Conceals the details of an algorithm in a function but system state information is not
hidden.
• Data-flow design
• Structural decomposition
System is viewed as a set of interacting objects, with their own private state.
Objects communicate by calling on services offered by other objects rather than sharing
• Active objects : owns a thread of control and can initiate control activity
11
Software Design Activities
In software design and architecture, several key activities are performed to ensure that a
software system is well-structured, maintainable, scalable, and meets the requirements of
stakeholders.
These activities generally occur during the planning and early stages of the software
development life cycle (SDLC). Here's a breakdown of the main activities:
1. Requirement Analysis
Objective: Understand and document what the system is supposed to do.
Activities: Gather functional and non-functional requirements from stakeholders.
Create use cases, user stories, and scenarios to capture system behaviors.
Prioritize requirements based on business value and technical feasibility.
12
Software Design Activities …
2. System Architecture Design
13
Software Design Activities …
3. High-Level Design (HLD)
Define interactions between components, using techniques like sequence diagrams and
flowcharts.
Specify key design patterns (e.g., MVC, Singleton, Factory) for the solution.
Write detailed class diagrams, including relationships like inheritance and associations.
Define data flow and logic for each function and method.
15
Software Design Activities …
5. Prototyping
Objective: Create a working model or simulation of the system to validate design decisions.
Activities: Build small, functional prototypes of key components or features.
Test assumptions regarding system behavior, performance, or usability.
Refine design based on feedback from stakeholders and users.
6. Design Validation
Objective: Ensure that the design meets the requirements and quality standards.
Activities: Conduct design reviews with stakeholders and technical teams.
Perform trade-off analysis between different design options.
Validate the design against functional and non-functional requirements. 16
Software Design Activities …
7. Technology Selection
Objective: Choose the tools, frameworks, and technologies for implementation.
Activities: Evaluate and select programming languages, development frameworks, and
libraries.
Choose databases, messaging systems, and middleware for integration.
Decide on tools for version control, CI/CD pipelines, testing, and monitoring.
8. Design Documentation
Objective: Record the design decisions, architecture, and guidelines for development.
Activities: Create technical specifications that detail the system’s architecture and design.
Maintain up-to-date documentation for APIs, database schemas, and system components.
17
Provide guidelines for coding standards, testing strategies, and deployment configurations.
Software Design Activities …
9. Risk Identification and Mitigation
Activities: Iterate on the design based on feedback from prototypes, early development, and
testing. 18
Design Considerations
Design considerations are specific factors or constraints that need to be taken into account
during the software design process.
These include:
1. Scalability
Consideration: Will the system need to handle increasing loads, such as more users or data?
Design Response: The system should be designed to scale horizontally (e.g., by adding more
servers) or vertically (e.g., by upgrading hardware).
2. Performance
Consideration: How fast should the system respond under different loads?
Design Response: Optimize for speed by reducing bottlenecks, minimizing database queries,
and caching frequently accessed data. 19
Design Considerations
Security
Consideration: What are the potential threats to the system’s data and functionality?
Design Response: Use encryption, secure authentication mechanisms, and follow security
best practices such as input validation and access controls.
Maintainability
Consideration: How easy is it to modify, extend, or fix the system in the future?
Design Response: Use modular design, clear documentation, and follow coding standards
that make the codebase easy to understand and update.
Usability
Consideration: Is the system intuitive and user-friendly for its intended users?
Design Response: Incorporate UX/UI best practices, conduct usability testing, and design
20
interfaces that are simple and effective.
Design Principles
Design principles are general rules or guidelines that influence the design of software
systems.
Adhering to these principles helps ensure the system is flexible, maintainable, and robust.
Separation of Concerns
Principle: Divide the system into distinct sections where each section addresses a separate
concern or functionality.
Example: In a web application, separate the business logic from the user interface and the
data access layer.
Single Responsibility Principle (SRP)
Principle: Every module or class should have one, and only one, reason to change, meaning
it should do one thing well.
Example: A class responsible for user authentication should not also handle database
queries.
21
Design Principles …
Open/Closed Principle (OCP)
Principle: Software entities should be open for extension but closed for modification.
Example: Use interfaces or abstract classes to allow new behaviors to be added without
changing existing code.
Liskov Substitution Principle (LSP)
Principle: Objects of a superclass should be replaceable with objects of a subclass without
affecting the correctness of the program.
Example: If Bird is a superclass and Penguin is a subclass, the system should be able to
handle Penguin where Bird is expected.
22
Design Principles …
Composition Over Inheritance
Principle: Prefer composing objects with smaller behaviors over inheriting behaviors from
parent classes.
Example: Instead of creating a class FlyingCar that inherits both Car and Airplane,
compose a class that includes Flyable and Driveable behaviors.
Favor High Cohesion and Loose Coupling
Cohesion: Modules should focus on a specific task and do it well, increasing readability and
maintainability.
Coupling: Dependencies between modules should be minimized to reduce the impact of
changes in one module on others.
23
Tackling Design Problem
• Any design problems must be tackled in three stages;
[detail design]
24
Tackling Design Problem
….
25
CHAPTER - 2
Design Patterns
What is a design Pattern?
need for amateur application designers to go that rough path (creating the design
solution) by them selves.
1. Creational Patterns
• provide various object creation mechanisms, which increase flexibility and reuse of
existing code.
2. Structural patterns
• concerned with how classes and objects can be composed, to form larger structures
3. Behavioral patterns
16
Creational Patterns
• if reuseability and changeability are desired qualities for the
…software
creational pattern.
29
A. Factory
Pattern
Definition:
The Factory pattern provides a way to use an instance as a
object factory. The factory can return an instance of one of
several possible classes (in a subclass hierarchy),
depending on the data provided to it.
If you have a class having several subclasses of
implementation based on the nature of the user input
(request type), then this pattern is an ideal solution to build
the selector with.
30
When is right to use the factory
pattern
When a class can't anticipate which kind of class of object it
must create.
When you have classes that are derived from the same
subclasses
When you want to insulate the client from the actual type
31
Factory pattern: Structure
32
Example
:
public abstract class Product { public class TestClientFactory {
public void writeName(String name)
public static void main(String[] args) {
{ System.out.println("My name is
ProductFactory pf = new
"+name); } ProductFactory();
}
Product prod;
public class ProductA extends Product { }
prod = pf.createProduct("A");
public class ProductB extends Product
{ public void writeName(String name) {
prod.writeName("John Doe");
StringBuilder tempName = new prod = pf.createProduct("B");
StringBuilder().append(name);
prod.writeName("John Doe");
System.out.println("My reversed name is" +
tempName.reverse()); }
}} }
public class ProductFactory { Product When TestClientFactory is executed
createProduct(String type)
the result is:
{ if(type.equals("B"))
• c:> My name is John Doe
return new ProductB();
else
• c:> My reversed name is eoD nhoJ
33
return
} new ProductA();
B. Abstract Factory
Pattern
• Definition
• The Abstract Factory pattern is a creational pattern related to the
Factory Method pattern, but it adds another level of abstraction.
• What this means is that the pattern encapsulates a group of individual
concrete factory classes (unlike the concrete factory methods which are
derived in subclasses) which share common interfaces.
• The client software uses the Abstract Factory which provides an
interface for creating families of related or dependent objects without
specifying their concrete classes.
• This pattern separates the implementation details of a set of
objects from its general usage.
22
Where to use the Abstract Factory
Design Pattern
• Use AF Pattern when:
You need to create sets of objects that share a common
theme and where the client only needs to know how to
handle the abstract equivalence of these objects, i.e.
the implementation is not important for the client.
The Abstract Factory is often employed when there is
a need to use different sets of objects and where the
objects could be added or changed some time during
the lifetime of an application.
35
Abstract Factory DP: Structure
36
Abstract Factory DP: participants & role
in
the structure
37
C. The Singleton Pattern
• Definition
38
Singleton Pattern:Where
to use
• When only one instance or a specific number of instances
of a class are allowed.
39
Singleton
pattern:Drawbacks/consequences
• Singleton pattern is also considered an anti-pattern
by some people, who feel
that it is overused, introducing
unnecessary limitations in situations where a sole
instance of a class is not actually required.
40
Singleton pattern:
Example
package com.logica.singleton;
public class FileLogger {
private static FileLogger
logger;
private FileLogger() {// made
private to Prevent clients
from using the constructor
}
//Control the accessible (allowed) instances
public static FileLogger getFileLogger()
{ if (logger == null) {
logger = new FileLogger();
}
return logger;
}
public synchronized void log(String msg) {
} Write to log file...
// 29
Design
Patterns
Structural Design Patterns
• “In software engineering, structural design
patterns are design patterns that ease the
design by identifying a simple way to realize
relationships between entities.”
• Structural Patterns describe how objects and classes can
be
combined to form structures.
• Hence, they help during designing a software Components’
structure.
class patterns Vs. object patterns
• We distinguish between object patterns and class patterns.
Behavioral Design
Patterns
Behavioral Object
Behavioral Class Patterns
Patterns
receivers.
• We place all receivers in a chain which lets the receiving objects pass the
request along to the next receiver in the chain until one receiver handles it,
• It reduces coupling.
• Drawbacks
54