https://www.youtube.com/watch?v=TMuno5RZNeE
Encapsulation ?
- OO weaken encapsulation by introducing
private
,public
,protected
Inheritance ?
- why Java doesn't have inheritance ? Diamond problem
Polymorphism
getChar
putChar
Polymorphism is the one thing in OOP that solves the problems of a bad code which are rigidity, fragility and non-usability
- responbility: sources of change
employee
calcPay() // CFO
reportHours() // COO
writeEmployee() // CTO
// This class has 3 responbilities
modules should be open for extension, close for modification
- for eg: when data source changed from rdb to file, we don't need to change the method
- no switch statement
Rectangle <- Square
- square is not substitubale for rectangle
- that violates LSP and will add if/else to code
- Small interface instead of fat
- compose if necessary
- new Keywork is glue
- https://deviq.com/principles/dependency-inversion-principle