Object Oriented Programming Concepts
OOPs concepts with Java examples. But this concepts stands valid for all OOP based programing languages
Four Principles
Encapsulation
- Mechanism of hiding of data implementation by restricting access to public methods
Abstraction
- One class should not know the inner details of another in order to use it
Inheritance
Polymorphism
SOLID Principles
Single Responsibility Principle
- One class should have one and only one responsibility . We should write, change and maintain a class for only one purpose
Open Closed Principle
- Software components should be open for extension, but closed for modification.
- Classes should be designed such a way that whenever fellow developers wants to change the flow of control in specific conditions in application, all they need to extend our class and override some functions
Liskov’s Substitution Principle
- Derived types must be completely substitutable for their base types . Objects of your subclasses to behave in the same way as the objects of your superclass
Interface Segregation Principle
- Clients should not be forced to implement unnecessary methods which they will not use. Each Interfaces should have a single responsibility principle holds to classes
Dependency Inversion Principle
- Depend on abstractions, not on cretions. Modules can be separated from each other using an abstract layer to bind them together
KISS
DRY
SoC
Read More