[go: up one dir, main page]

0% found this document useful (0 votes)
8 views2 pages

SOLID Principles Exercise

Uploaded by

itsmeceth00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

SOLID Principles Exercise

Uploaded by

itsmeceth00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Slide 1: Laboratory Exercise 1 Requirements Elicitation

Applying SOLID Principles with Class Diagrams

Slide 2: Introduction
SOLID Principles Overview SOLID is a set of design principles to make software easier to maintain:
- SRP: Single Responsibility Principle - OCP: Open-Closed Principle - LSP: Liskov Substitution
Principle - ISP: Interface Segregation Principle - DIP: Dependency Inversion Principle

Slide 3: Single Responsibility Principle (SRP)


Before: Invoice handles calculation + printing After: Invoice class + InvoicePrinter class Each class
should have only one reason to change. Splitting responsibilities ensures maintainability.

Slide 4: Open-Closed Principle (OCP)


Before: Shape class with if-statements for Circle, Rectangle After: Base Shape class, extended by
Circle and Rectangle Classes should be open for extension but closed for modification. New
shapes can be added without modifying existing code.

Slide 5: Liskov Substitution Principle (LSP)


Before: Bird class with fly() — Penguin cannot fly After: Bird -> FlyingBird, NonFlyingBird Subtypes
must be substitutable for their base type. Separating flying and non-flying birds ensures
correctness.

Slide 6: Interface Segregation Principle (ISP)


Before: IMachine interface with print(), scan(), fax() — Not all machines support all After: IPrinter,
IScanner, IFax interfaces Clients should not be forced to depend on methods they do not use.
Smaller interfaces are better.

Slide 7: Dependency Inversion Principle (DIP)


Before: PaymentProcessor depends on CreditCard class After: PaymentProcessor depends on
IPaymentMethod interface High-level modules should depend on abstractions, not concrete
implementations. This allows flexibility and testing.
Slide 8: Conclusion
SOLID Applied By applying SOLID principles, we improve flexibility, reduce coupling, and make the
system easier to maintain and extend.

You might also like