Summery For SDA
Summery For SDA
http://www.mahergelle.com
Chapter TWo: -
Software Architecture
Introduction
Software Architecture and Design
• A
Goals of Architecture
Software Architecture and Design
Software
Design
Principles
Software Design
Principles
Software design principles are fundamental guidelines that
help developers create clean, maintainable, and scalable
software.
Applying these principles leads to more robust and efficient
software systems that are easier to test and debug.
Understanding these principles is essential for software
engineers.
Before After
A class with multiple responsibilities Breaking down a class into smaller
is hard to maintain, test and classes makes testing, refactoring, and
understand.
reuse easier.
Open/Closed
Principle (OCP)
The Open/Closed Principle (OCP) asserts that software entities (classes,
modules, functions, etc.) should be open for extension but closed for
modification.
This principle enables you to add new functionality without altering
existing code, reducing the risk of introducing bugs. Using inheritance or
interfaces, you can extend functionality while ensuring that the original
class remains stable and unchanged.
Original
Class for Modification.
Closed
Inheritance
/Interfaces
Open for Extension
New
Functionali
Added without modifying the Original Class.
ty
Liskov Substitution
Principle (LSP)
The Liskov Substitution Principle (LSP) states that subtypes must be substitutable for their base types
without altering the correctness of the program.
In other words, if you have a base class and several derived classes, you should be able to use any of the
derived classes in place of the base class without causing unexpected behavior. This ensures that
inheritance is used correctly and promotes a robust design.
Subtype 1
2 Extends the base functionality.
Base Class 1
Defines the base functionality.
Subtype 2
Can be used interchangeably with the Base
3 Class
Interface Segregation
Principle (ISP)
The Interface Segregation Principle (ISP) advises that clients should not be forced to depend on interfaces they do not
use.
Instead of having one large interface with many methods, it is better to split it into smaller, more specific interfaces.
This reduces the dependencies and prevents classes from implementing methods they don't need, leading to a more
modular and maintainable codebase, and easier refactoring.
Before After
A large interface forces classes to implement Smaller, specific interfaces reduce dependencies and
unnecessary methods. promote clean code.
Other Important
Principles
Beyond the SOLID principles, there are several other design principles that can significantly improve the quality of your
code. These principles focus on simplicity, avoiding redundancy, and planning for future needs without
over-engineering.
DRY
1
Don’t Repeat
Yourself.
KISS
2
Keep It Simple,
Stupid.
YAGNI
3
You Ain’t Gonna
Need It.
4 High Cohesion & Low
Coupling
Benefits of Design
Principles
40% 30%
Reduced Faster
Bugs
Fewer bugs due to modular Develop
Increased development
and testable code.
ment
speed due to code
reusability
50%
Lower
Costs costs
Lower maintenance
due to clean architecture.
Today's Agenda
Architectural
Styles
Architectural Styles: The Big
Picture
Architectural styles are reusable solutions to common design problems, providing a high-level system organization. They help in
defining the overall structure and behavior of a software system, ensuring that all components work together harmoniously.
Layered
Organizes the system into horizontal layers.
Client-Server
Divides the system into client and server components.
MVC
Separates the application into model, view, and controller.
Layered Architecture: Structure and
Separation
Layered architecture organizes a system into horizontal layers, each performing a specific role. This
modular approach promotes separation of concerns, making the system easier to understand,
maintain, and test.
Layers Benefits Considerations
• Presentation • Easy to understand • Performance overhead
• Business Logic • Maintainability • Tight coupling
• Data Access • Testability
• Database
Layered Architecture:
Structure and
Separation
Client-Server Architecture: A Central
The client-server architecture divides the system into two distinct parts: the client, which requests
Hub
services, and the server, which provides those services. This model is fundamental to many
network-based applications, offering scalability and centralized control.
500K 1 99.9%
Clients Server Uptime
Potential client connections Number of servers in the example Server uptime guarantee
deployment
Model-View-Controller (MVC):
Separation of Concerns
The MVC pattern separates an application into three interconnected
parts: the Model (data and business logic), the View (user interface),
and the Controller (user input and application flow). This separation
enhances maintainability and testability.
1 Model
Data and business logic
2 View
User interface
3 Controller
User input and application flow
Diagrams
Software Architecture and Design