sad3
sad3
Software Design
Pattern
Software architecture patterns and software design patterns are both essential
concepts in software engineering, but they operate at different levels of abstraction.
Let’s break them down with definitions, examples, and differences.
Definition:
An architecture pattern defines the high-level structure of a software system. It
focuses on how components of the system interact and are organized, ensuring
scalability, maintainability, and reliability.
Characteristics:
High-level design.
Deals with the overall system organization.
Focuses on communication between subsystems or modules.
Examples:
Layered Architecture: Divides the system into layers like presentation, business logic, and
data.
Microservices Architecture: A system divided into independently deployable, loosely
coupled services.
Client-Server Architecture: A system with centralized servers and distributed clients.
Scenario:
An e-commerce platform might use a microservices architecture to separate
services like inventory, payment, and user management for better scalability.
Diagram:
sql
Copy code
+-------------------+| User Interface | <- Presentation
Layer+-------------------+| Business Logic | <- Business
Layer+-------------------+| Database Access | <- Data
Layer+-------------------+| Database | <- Storage
Layer+-------------------+
Definition:
A design pattern is a reusable solution to a common problem within a specific context
in the software design phase. It focuses on the interaction between objects and classes.
Characteristics:
Examples:
Singleton Pattern: Ensures a class has only one instance and provides a global access point.
Factory Pattern: Provides a way to instantiate objects without exposing the creation logic.
Observer Pattern: Defines a one-to-many dependency where multiple objects are notified of
changes to another object.
Scenario:
In the e-commerce platform, a factory pattern could create product objects
dynamically based on the type (e.g., electronics, clothing).
lua
Copy code
Factory
|
+---> ProductA
|
+---> ProductB
3. Key Differences
Example in Action
1.
Architecture Pattern:
Use a microservices architecture to separate services for:
2.
o Video encoding.
o User authentication.
o Content delivery.
3.
Design Pattern:
Inside the video encoding service, use:
4.
Combined Diagram:
Architecture (Microservices):
diff
Copy code
+--------------------------------------+
| Video Streaming Platform |+----------------+---------------------+
| Auth Service | Encoding Service |
| Content Service| Notification Service|+----------------+---------------------
+
scss
Copy code
EncodingEngine (Singleton)
|
+--> ProgressTracker (Observer)
+--> NotificationModule (Observer)
This illustrates how architecture patterns and design patterns complement each other.
The architecture defines the system's structure, while design patterns solve problems
within that