DAY 21
πΒ μ€λ μ½μ λ²μ : 10μ₯ λ
<aside>
π μ±
μμ κΈ°μ΅νκ³ μΆμ λ΄μ©μ μ¨λ³΄μΈμ.
</aside>
- ...another key OO class design principle known as the Open-Closed Principle, or OCP. Classes should be open for extension but closed for modification.
- Needs will change, therefore code will change. We learned in OO 101 that there are concrete classes, which contain implementation details (code), and abstract classes, which represent concepts only. A client class depending upon concrete details is at risk when those details change. We can introduce interfaces and abstract classes to help isolate the impact of those details.
- The lack of coupling means that the elements of our system are better isolated from each other and from change. This isolation makes it easier to understand each element of the system.
- By minimizing coupling in this way, our classes adhere to another class design principle known as the Dependency Inversion Principle (DIP). In essence, the DIP says that our classes should depend upon abstractions, not on concrete details.
<aside>
π€ μ€λ μ½μ μκ°μ? λ μ€λ₯΄λ μκ°μ κ°λ³κ² μ μ΄λ³΄μΈμ
</aside>
Class chapter is generally difficult for me as I never use Class. I think I understand the concept but canβt think of any personal experiences related to this.
<aside>
π κΆκΈν λ΄μ©μ΄ μκ±°λ, μ μ΄ν΄λμ§ μλ λ΄μ©μ΄ μλ€λ©΄ μ μ΄λ³΄μΈμ.
</aside>
<aside>
π‘ μκ° 3μ€ μμ½
</aside>
- Itβs better to make classes not depend upon each other. Dependency Inversion Principle.
- Classes should be open for extension but closed for modification. Open-Closed Principle.