Home IoC vs Factory Pattern
Post
Cancel

IoC vs Factory Pattern

IoC vs Factory Pattern

๐Ÿ˜ต ์ฐจ์ด์ 

Factory Pattern์„ ์“ฐ๋ฉด ํ•ด๋‹น ๊ฐ์ฒด๊ฐ€ Factory์— ๊ฐ•ํ•œ ์˜์กด์„ฑ์„ ๊ฐ€์ง€๊ฒŒ ๋œ๋‹ค. ์ฆ‰, ํ•ด๋‹น ๊ฐ์ฒด์—์„œ Factory๋ฅผ ํ˜ธ์ถœํ•ด์•ผํ•œ๋‹ค.

1
2
3
class Button {
    private final Lamp lamp = Factory.getLamp();
}

ํ•˜์ง€๋งŒ, IoC Container๋ฅผ ์“ฐ๋ฉด ํ•ด๋‹น ๊ฐ์ฒด ์™ธ๋ถ€์—์„œ ์ƒ์„ฑ์ž ๋˜๋Š” Setter๋ฅผ ํ†ตํ•ด ๊ฐ์ฒด๋ฅผ ๋ฐ›๊ฒŒ๋œ๋‹ค.

1
2
3
4
5
6
7
class Button {
    private final Lamp lamp;
    
    public Button(Lamp lamp) {
        this.lamp = lamp;
    }
}
This post is licensed under CC BY 4.0 by the author.

@PrimaryKeyJoinColumn์ด๋ž€

S3์˜ ์ธ์ฆ์„œ๊ฐ€ ์˜ฌ๋ฐ”๋ฅด์ง€ ์•Š๋‹ค๊ณ  ๋œฐ ๋•Œ ํ•ด๊ฒฐ๋ฒ•