Skip to content

anuragSharma1112/Solid-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOLID Principles in Java

This project demonstrates the 5 SOLID principles of Object-Oriented Programming using Java.
Each principle is implemented in its own package with simple, real-world inspired examples.


📌 SOLID Principles Covered

1. Single Responsibility Principle (SRP)

  • A class should have only one reason to change.
  • Example: Separation of InvoicePrinter and InvoiceSaver from Invoice.

2. Open/Closed Principle (OCP)

  • Classes should be open for extension but closed for modification.
  • Example: Adding new Shape types without modifying existing code.

3. Liskov Substitution Principle (LSP)

  • Subtypes must be substitutable for their base types.
  • Example: Dog and Cat can be used wherever Animal is expected.

4. Interface Segregation Principle (ISP)

  • Clients should not be forced to depend on methods they do not use.
  • Example: Separate interfaces for Printer, Scanner, Fax.

5. Dependency Inversion Principle (DIP)

  • High-level modules should not depend on low-level modules, but on abstractions.
  • Example: NotificationService depends on MessageSender interface, not directly on EmailSender.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages