Liskov Substitution Principle

Liskov Substitution Principle References Liskov Substitution Principle (Wikipedia) LSP article (Uncle Bob) Design by Contract (Wikipedia) Introduction Previously, the core mechanism of OCP (Open/Closed Principle) was to use abstraction and polymorphism. By using inheritance, you could create derived classes from an abstract base class. So, what design rules govern this kind of special inheritance? What are the characteristics of the best inheritance hierarchies? What causes hierarchies that do not conform to OCP? ...

October 11, 2020

Open Closed Principle

Open-Closed Principle Classes, modules, and functions should be open for extension but closed for modification. - MEYER Bertrand(1988) Object-Oriented Software Construction Allow extension, but do not allow modification. In other words, a class should be extensible without modification. How to Implement the Principle There are two methods. Both use generalization, but differ in their goals, techniques, and results. 1. Meyer’s Open-Closed Principle Method Implement using inheritance. Explanation By using inheritance, the parent class can be implemented through inheritance, so it is open for extension. Since the parent class is accessed through the child class, the parent class can be hidden and thus closed for modification. ...

October 11, 2020

Prototype Pattern

What is the Prototype Pattern? The Prototype Pattern is a creational design pattern. It enables the creation of new objects by copying an existing object, rather than creating them from scratch via their class constructors. This helps decouple code from specific classes. Prototype: Common vs Software Usage When I first encountered the Prototype Pattern, I was confused. The word “prototype” in daily use has a slightly different meaning, so let’s clarify that first. ...

October 11, 2020

Single Responsibility Principle

Single Responsibility Principle Source https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html Question What exactly is a reason to change? How people interpret “reason to change” Bug fix? Refactoring? Core Idea Relate “reason to change” with “responsibility”. The above two are the programmer’s responsibility. => Who should the program’s design respond to?! Example 1. CEO Reporting to the CEO is a C-Level decision (CFO, COO, CTO). 2. CFO Responsible for controlling finance. 3. COO Responsible for operating the company. ...

October 11, 2020

Singletone Pattern

References: Refactoring Guru - Singleton Pattern Wikipedia - Singleton Pattern jeong-pro 블로그 What is the Singleton Pattern? The Singleton Pattern is a creational design pattern that ensures a class has only one instance and provides a global point of access to it. When is it used? It’s useful in situations where exactly one object is needed to coordinate actions across the system—like: Database connection A shared configuration object A centralized logging service These are cases where a single, globally accessible instance makes sense. ...

October 11, 2020

[Spring] Circular Reference Error Caused by Field Injection

References edwith DobiSocks reviewer https://www.mimul.com/blog/di-constructor-injection/ (Why DI is needed) https://madplay.github.io/post/why-constructor-injection-is-better-than-field-injection (Why constructor injection is recommended over field injection) https://d2.naver.com/helloworld/1230 (JVM Internal) Overview In an edwith course, I submitted a project using field injection for DI. However, the reviewer recommended constructor injection and kindly provided related materials. Although I understood most of the points, I didn’t quite get how constructor injection prevents circular reference errors, so I decided to summarize it here. ...

June 1, 2020

[JavaScript] Asynchronous Processing Problem

[JavaScript] Asynchronous Processing Problem Recently, even after completing the edwith Boostcourse, I couldn’t understand why callback hell occurs. I finally understood it while working on a Naver page. Problematic Process Click the Tab UI. Display the total list count 2-1) Request the total list count via Ajax API. (If cached, go directly to 2-3) 2-2) Cache the received API data. 2-3) Display the total list count using the cached data. Show the items under the UI tab 3-1) Request product information (items) via Ajax API. (If cached, go directly to 3-3) 3-2) Cache the received API data. 3-3) Display the product information using the cached data. This was the process, and I implemented it as follows: ...

May 23, 2020

Fixture Monkey Example

Fixture Monkey Example Fixture Monkey - https://naver.github.io/fixture-monkey/v1-0-0/ For readability, it is recommended to copy and paste the code into your IDE. 1 // ... (all code blocks and explanations translated to English, preserving structure) (Translate all explanations, comments, and section headings to English. Keep all code blocks as-is. If you want the full translation, let me know and I will provide the complete English markdown.)