Practical Guide to Object Oriented Programming
Table of Content
- Our Journey Thus Far...
- Taking a step back...
- OOP Fundamentals
OUR JOURNEY THUS FAR...
WHAT HAVE WE LEARNT SO FAR?
-
Intro to OOP Concepts by Asyrul
- Understanding OOP
- Why OOP
- 4 Pillars of OOP
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
- SOLID Principles
- 12 Factors
- Design Patterns
WHAT HAVE WE LEARNT SO FAR?
- Intro to OOP Concepts
-
SOLID Principles
- Single Responsibility Principles
- Open Closed Principles
- Liskov Subtitution Principles
- Inversion of Control
- Dependency Inversion Principles
- 12 Factors by Syafiq
- Design Patterns
WHAT HAVE WE LEARNT SO FAR?
- Intro to OOP Concepts
- SOLID Principles
-
12 Factors App by Syafiq
- Git Repository
- Dependency/Package Manager
- Config in Environment Variables
- Separate Build & Run Stages
- Port Binding
- Services as Attached Resources
- Concurrency (Ability to scale up)
- Disposability (Ability to scale down)
- Stateless Processes
- Logs
- Run Migration as one-off processes
- Keep Dev, Staging, Prod Env as similar as possible
- Design Patterns
WHAT HAVE WE LEARNT SO FAR?
LET'S TAKE A STEP BACK...!
We learnt too much concepts, but unable to apply it into practise..
Btw, just simply creating a subclass which inherit a superclass does not mean you're applying OOP correctly...
So let's go back to the fundamental & basic principles that we should know.
The OOP Fundamentals
- Hide Implementation Details
- Composition over Inheritance
- Seperation of Concerns
- Encapsulate What Changes
- Delegation Principles
- Minimise Coupling
- Code For the Maintainer
- DRY
- Curly's Law
Hide Implementation Details
Why
How
- When the implementation changes, the interface clients are using does not have to change.
- Minimize accessibility of classes and members.
- Don’t expose member data in public.
- Avoid putting private implementation details into a class’s interface.
- Decrease coupling to hide more implementation details.
Composition Over Inheritence
Why
How
- Less Coupling
- Inheritance easily make assumptions & break LSP
- Compose when there is a 'has-a'
- Inherit when 'is-a'
Encapsulate What Changes
Why
How
- Minimise required modifications when a change occurs
- Encapsulate the concept that varies behind an API
- Separate the varying concept into its own module
Delegation principle
Why
How
- No duplication of code
- Don’t do all stuff by yourself, delegate it to the respective class
Seperation of Concerns
Why
How
- Simplify development & maintenance
- Promotes Re-usability
- Break program functionality into separate modules that overlaps as little as possible
References
- Programming Principles - Github
- 10 OOP Design Principle Every Programmer should know - Hackernoon
Practical Object Oriented
By Wan Mohd Hafiz
Practical Object Oriented
- 222