Skip to content

Commit

Permalink
refactor:Configuration 클래스에 싱글톤 패턴 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
whrjsgml0000 committed Oct 19, 2024
1 parent 71f7fed commit e9e5596
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/calculator/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import calculator.controller.CalculatorController;

public class Application {
private static final Configuration configuration = new Configuration();
private static final Configuration configuration = Configuration.getInstance();

public static void main(String[] args) {
CalculatorController calculatorController = configuration.getCalculatorController();
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/calculator/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import calculator.service.CalculatorService;

public class Configuration {
private final CalculatorController calculatorController;
private static final Configuration configuration = new Configuration();
private final CalculatorController calculatorController = new CalculatorController();

public Configuration() {
this.calculatorController = new CalculatorController();
private Configuration() {
}

public static Configuration getInstance() {
return configuration;
}

public CalculatorController getCalculatorController() {
Expand Down

0 comments on commit e9e5596

Please sign in to comment.