SDA Assignmnent 1
SDA Assignmnent 1
ASSIGNME
NT 01
MUHAMMAD AHMAD RAZA
RIDA WAHEED
ANAS REHMAN
Introducti
vary independently.
[geekforgeeks.com]
on
Example: Shapes and color
classes
• Identify Independent Dimensions :
Apply for systems with multiple
orthogonal extensions. [2]
• Favor Composition Over
Do’s of Inheritance : Use composition to
reduce coupling. [2]
Bridge • Define Clear Abstractions : Ensure
Design well-structured abstraction and
implementation hierarchies.[1]
Pattern • Keep Interfaces Focused : Adhere
to Interface Segregation Principle. [1]
• Document Code : Maintain clarity
and ease of maintenance. [1]
• Avoid Unnecessary Abstractions :
Don’t overcomplicate without clear
benefits. [1]
• Prevent Interface Overload : Keep
Don’ts of methods relevant and minimal. [1]
• Use Clear Naming : Avoid vague
Bridge class/method names. [1]
Design • Handle Variability Properly : Ensure
implementations remain flexible. [1]
Pattern • Leverage the Pattern Fully : Maintain
abstraction-implementation separation.[2]
Enables Shared
Decouples
Implementations
Abstraction &
– Useful for
Implementation –
reference counting
Allows changing
and object sharing.
implementations at
runtime.
Supports
use :
hierarchies.
can evolve
separately.
Encapsulates
Improves
Implementation –
Maintainability –
Hides
Changes in
implementation
implementation
details from clients
don’t affect clients.
(useful in C++).
Intent:
• Make incompatible things work
together.
• Wrap an existing class to fit new needs.
Example:
• A `USBCharger` needs to work with a
`TypeC` device. An adapter makes the
- [1] Design Patterns:
USB look Elements
like Type-C of Reusable
to the device. It
Object-Oriented Software
translates requests (p. 139)
so they match.
Strategy Pattern
-Strategy Pattern:
- Dynamic behavior but with increased object count.
- You can change how things work whenever you
want, but you might end up with more stuff to
manage.
- "Strategy lets the algorithm vary independently
from clients".[6]
- "Each strategy is a separate class". [7] potentially
leading to more objects in the system.