Factory Method Pattern

์ตœ์ค€ํ˜ธยท2022๋…„ 11์›” 13์ผ
0

Design Pattern

๋ชฉ๋ก ๋ณด๊ธฐ
3/7
post-thumbnail

๐Ÿ“— Factory Method Pattern

๊ฐ์ฒด์˜ ์ƒ์„ฑ ์ฑ…์ž„์„ ์ถ”์ƒ ํด๋ž˜์Šค(or ์ธํ„ฐํŽ˜์ด์Šค)์˜ ๋ฉ”์„œ๋“œ์— ๋งก๊ธฐ๋Š” ํŒจํ„ด์ด๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ์ฐจ๋ฅผ ๋งŒ๋“œ๋Š” ๊ณต์žฅ์ด ์žˆ๋‹ค. ์ตœ์ดˆ์—๋Š” ์•„๋ฐ˜๋–ผ๋งŒ ์ฐ์–ด๋ƒˆ์—ˆ๋Š”๋ฐ. ๊ณต์žฅ์ด ๋„ˆ๋ฌด ์ž˜๋ผ์„œ G70, GV80 ๋“ฑ ์ƒˆ๋กœ์šด ์ฐจ ๋ผ์ธ์ด ํ•„์š”ํ•˜๋‹ค. ํ•˜์ง€๋งŒ ์ฐจ๋Š” ๊ธฐ๋ณธ์ ์ธ ๋ถ€ํ’ˆ์„ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์€ ๋™์ผํ•˜๋‹ค. ํ•˜์ง€๋งŒ ์ฐจ๋Ÿ‰์˜ ๋งˆํฌ๋ผ๋˜์ง€ ๋ฐ”ํ€ด๋ผ๋˜์ง€ ๋‹ค๋ฅด๊ฒŒ ์ ์šฉ์ด ํ•„์š”ํ•œ ๋ถ€๋ถ„์ด ์žˆ๋‹ค.

์ด๋ฅผ ์ฝ”๋“œ๋กœ์จ ๋ฌด์‹ํ•˜๊ฒŒ ํ•ด๊ฒฐํ•˜๋ฉด

if(car.name.equals("์•„๋ฐ˜๋–ผ")){
	...
}else if(car.name.equals("GV80")){
	...
}else if(car.name.equals("G70")){
	...
}

๊ณผ ๊ฐ™๊ฑฐ๋‚˜ ๋” ์‹ฌ๊ฐํ•˜๊ฒŒ ๋ถ„๊ธฐ์ฒ˜๋ฆฌ๋˜๋Š” ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ• ์ง€๋„ ๋ชจ๋ฅธ๋‹ค.

ํ•˜์ง€๋งŒ ์ด๋Ÿฐ ์ฝ”๋“œ๋ฅผ ์งœ๋ฉด ์‹œ๋Œ€์— ํ๋ฆ„์— ๋งž๊ฒŒ ๋„ค๋น„๊ฒŒ์ด์…˜์„ ์ผ๊ด„์ ์œผ๋กœ ์ ์šฉํ•œ๋‹ค๋˜์ง€ ์ฐจ์˜ ๋กœ๊ณ ๋ฅผ ๋ณ€๊ฒฝํ•œ๋‹ค๋˜์ง€ ๋“ฑ์˜ ์ž‘์—…์ด ์ƒ๊ธฐ๋ฉด ์ฝ”๋“œ๊ฐ€ ๋ชจ๋‘ ์ˆ˜์ •์ด ์ผ์–ด๋‚œ๋‹ค.

๊ทธ๋ž˜์„œ ์šฐ๋ฆฌ๋Š” Factory Method Pattern์„ ์ด์šฉํ•˜์—ฌ ์ข€ ๋” OPC๋ฅผ ์ง€ํ‚ค๋Š” ์ฝ”๋“œ๋กœ ํƒ„์ƒ์‹œ์ผœ๋ณด์ž.

โŒจ๏ธ ํŒจํ„ด์ด ์ ์šฉ๋˜์ง€ ์•Š์€ ์ฝ”๋“œ

๐Ÿ“„ ์ฝ”๋“œ ์ž‘์„ฑ

public class Car {
    private String name;
    private String color;
    private String logo;
    private String engine;

    ... getter, setter, toString
}

Car๋ผ๋Š” class๋ฅผ ๋งŒ๋“œ๋ ค๋ฉด ์ž๋™์ฐจ ์ด๋ฆ„๊ณผ ์—”์ง„์„ ์ •์˜ํ•ด์•ผํ•œ๋‹ค๊ณ  ํ•˜์ž.

public class AvanteFactory {

    public static Car createCar(String owner, String color){
        // validate
        if(owner.isEmpty()) throw new IllegalArgumentException("์†Œ์œ ์ž๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
        if(color.isEmpty()) throw new IllegalArgumentException("์ƒ‰์ƒ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");

        System.out.println("Avante ์ƒ์‚ฐ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.");
        Car car = new Car();
        car.setOwner(owner);

        System.out.println("Avante ์ƒ์‚ฐ์ค‘...");
        car.setEngine("v1");
        car.setColor(color);
        car.setLogo("ํ˜„๋Œ€");
        car.setName("Avante");

        System.out.println("Avante๋ฅผ ๋งŒ๋“œ๋Š”๋ฐ ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.");

        return car;
    }
}
public class GV80Factory {

    public static Car createCar(String owner, String color){
        // validate
        if(owner.isEmpty()) throw new IllegalArgumentException("์†Œ์œ ์ž๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
        if(color.isEmpty()) throw new IllegalArgumentException("์ƒ์‚ญ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");

        System.out.println("GV80 ์ƒ์‚ฐ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.");
        Car car = new Car();
        car.setOwner(owner);

        System.out.println("GV80 ์ƒ์‚ฐ์ค‘...");
        car.setEngine("v1+");
        car.setColor(color);
        car.setLogo("์ œ๋„ค์‹œ์Šค");
        car.setName("GV80");

        System.out.println("GV80์„ ๋งŒ๋“œ๋Š”๋ฐ ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.");

        return car;
    }
}

๊ทธ๋ฆฌ๊ณ  Car๋ฅผ ๋งŒ๋“ค์–ด์„œ ๋ฐ˜ํ™˜์‹œ์ผœ์ฃผ๋Š” factory class๋“ค์„ ์ •์˜ํ–ˆ๋‹ค.

public class Client {
    public static void main(String[] args) {
        Car car1 = AvanteFactory.createCar("์ตœ์ค€ํ˜ธ", "white");
        Car car2 = GV80Factory.createCar("์ตœ์ค€ํ˜ธ", "black");
        System.out.println(car1.toString());
        System.out.println(car2.toString());
    }
}

๊ทธ๋ฆฌ๊ณ  ์ฐจ๋ฅผ ๋งŒ๋“ค๋ฉด

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฐจ๋Ÿ‰์„ ์ •์ƒ์ ์œผ๋กœ ์ƒ์‚ฐํ•ด๋‚ผ ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์—ฌ๊ธฐ์—๋Š” ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š”๋ฐ. ๋งŒ์•ฝ ๋„ค๋น„๊ฒŒ์ด์…˜์„ ์ถ”๊ฐ€๋กœ ๋‹ฌ์•„์•ผํ•  ๊ฒฝ์šฐ factory class๋งˆ๋‹ค ์ฐพ์•„๊ฐ€์„œ ์ฝ”๋“œ๋ฅผ ๋ณ€๊ฒฝํ•ด์•ผํ•˜๋ฉฐ, ์ฐจ๋Ÿ‰ ์ƒ์‚ฐ์„ ์œ„ํ•ด ์ง„ํ–‰๋˜๋Š” ๊ณผ์ •์ด ์ค‘๋ณต๋˜์–ด ์œ ์ง€๋ณด์ˆ˜๊ฐ€ ๋ฐœ์ƒํ•  ๊ฒฝ์šฐ์—๋„ ๋ชจ๋“  factory class์— ์ฝ”๋“œ์— ์ˆ˜์ •์ด ๋ฐœ์ƒํ•œ๋‹ค๋Š” ์ ์ด๋‹ค.

โŒจ๏ธ ํŒจํ„ด์„ ์ ์šฉ์‹œํ‚ค๋Š” ์ฝ”๋“œ

๐Ÿ“„ ๊ณตํ†ต ๋ถ€๋ถ„ interface๋กœ ๋นผ๊ธฐ

public interface CarFactory {
    default Car orderCar(String owner, String color){
        validate(owner, color);
        Car car = createCar();
        prepare(car);
        settingCar(car, owner, color);
        complete(car);
        return car;
    }

    private void validate(String owner, String color){
        if(owner.isEmpty()) throw new IllegalArgumentException("์†Œ์œ ์ž๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
        if(color.isEmpty()) throw new IllegalArgumentException("์ƒ‰์ƒ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
    }

    private void prepare(Car car){
        System.out.println(car.getName()+" ์ƒ์‚ฐ์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.");
        System.out.println(car.getName()+" ์ƒ์‚ฐ์ค‘...");
    }

    private void settingCar(Car car, String owner, String color){
        car.setOwner(owner);
        car.setColor(color);
    }

    private void complete(Car car){
        System.out.println(car.getName()+"์„ ๋งŒ๋“œ๋Š”๋ฐ ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.");
    }

    // ๊ตฌํ˜„ํ•ด์•ผํ•˜๋Š” ๋ถ€๋ถ„
    Car createCar();
}

๋‹ค์Œ๊ณผ ๊ฐ™์ด interface๋ฅผ ์ž‘์„ฑํ•˜๋ฉฐ ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง์„ ์ง„ํ–‰ํ•ด๋ณด์•˜๋‹ค. ์ค‘๋ณต์ฒ˜๋ฆฌ ๋˜๋Š” ๋ถ€๋ถ„์€ ๋ชจ๋‘ interface ๋‚ด method๋กœ ๋นผ๊ณ  ์‹ค์ œ๋กœ ๊ตฌํ˜„ํ•ด์•ผํ•  ๋ถ€๋ถ„์ธ createCar() method๋งŒ ๊ตฌํ˜„ class์—์„œ ์ •์˜ํ•˜๋ฉด ๋œ๋‹ค.

interface์—์„œ private method๋Š” java9 ์ด์ƒ์—์„œ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋ฏ€๋กœ java 8์„ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์ค‘๊ฐ„์— interface๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ์ถ”์ƒ ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ๋„ฃ์–ด์ฃผ์–ด์•ผํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ทธ ์ถ”์ƒ ํด๋ž˜์Šค๋ฅผ ๋‹ค๋ฅธ ๊ตฌํ˜„ ํด๋ž˜์Šค๋“ค์ด ๋‹ค์‹œ ๊ตฌํ˜„ํ•ด์ฃผ์–ด์•ผํ•œ๋‹ค.

๐Ÿ“„ AvanteV2 ์ •์˜

public class AvanteV2 extends Car {
    public AvanteV2() {
        setName("Avante");
        setEngine("v2");
        setLogo("ํ˜„๋Œ€");
    }
}
public class AvanteFactoryV2 implements CarFactory{
    @Override
    public AvanteV2 createCar() {
        return new AvanteV2();
    }
}

๊ทธ๋ฆฌ๊ณ  AvanteFactoryV2๋Š” CarFactory๋ฅผ ๊ตฌํ˜„ํ•˜๋Š”๋ฐ createCar๋งŒ ๊ตฌํ˜„ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ๋ฌผ๋ก  ์—ฌ๊ธฐ์„œ๋Š” AvanteV2๋ฅผ ๋ฐ˜ํ™˜์‹œํ‚ค๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ฝ”๋“œ๋ฅผ ํฌ๊ฒŒ ์ž‘์„ฑํ•  ํ•„์š”๋Š” ์—†๋‹ค.

public class Client {
    public static void main(String[] args) {
        Car car1 = new AvanteFactoryV2().orderCar("์ตœ์ค€ํ˜ธ", "white");
        System.out.println(car1.toString());
    }
}

๊ทธ๋Ÿผ ์‹ค์ œ๋กœ orderCar() mehtod๋ฅผ ํ†ตํ•ด ์‹คํ–‰์„ ํ•ด๋ณด๋ฉด

์ด์ „๊ณผ ๋™์ผํ•˜๊ฒŒ ์ƒ์‚ฐ์„ ํ•ด๋‚ผ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋Ÿผ ์ด์ œ ์ด ์ฝ”๋“œ๊ฐ€ ์ง„์งœ๋กœ OCP๋ฅผ ์ง€ํ‚ฌ ์ˆ˜ ์žˆ์„๊ฒƒ์ธ๊ฐ€? GV80์„ ์ƒ์‚ฐํ•ด๋‚ด๋ฉฐ ํ™•์ธํ•ด๋ณด์ž!

๐Ÿ“„ GV80V2 ์ •์˜

public class GV80V2 extends Car {
    public GV80V2() {
        setName("GV80");
        setEngine("v2+");
        setLogo("์ œ๋„ค์‹œ์Šค");
    }
}
public class GV80FactoryV2 implements CarFactory{
    @Override
    public Car createCar() {
        return new GV80V2();
    }
}

์—ฌ๊ธฐ์„œ ํŒจํ„ด์˜ ํž˜์„ ๋Š๋‚„ ์ˆ˜ ์žˆ์—ˆ๋Š”๋ฐ. ๊ทธ ์–ด๋–ค ์ฝ”๋“œ์˜ ์ˆ˜์ •๋„ ์—†์ด GV80V2 GV80FactoryV2 ๋‘๊ฐœ์˜ class๋งŒ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์œผ๋กœ ์ฐจ๋Ÿ‰ ์ƒ์‚ฐ ์ฝ”๋“œ๊ฐ€ ๋๋‚ฌ๋‹ค.

์ด๋ฅผ ํ†ตํ•ด ์šฐ๋ฆฌ๋Š” OCP๋ฅผ ์ž˜ ์ง€ํ‚จ ์ฝ”๋“œ๋ฅผ ์ƒ์‚ฐํ•ด๋ƒˆ๋‹ค๊ณ  ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ๋‹ค.

public class Client {
    public static void main(String[] args) {
        Car car1 = new AvanteFactoryV2().orderCar("์ตœ์ค€ํ˜ธ", "white");
        Car car2 = new GV80FactoryV2().orderCar("์ตœ์ค€ํ˜ธ", "white");
        System.out.println(car1.toString());
        System.out.println(car2.toString());
    }
}

์ด๋ฒˆ์—” ๋‘ ์ฐจ๋Ÿ‰์„ ๋™์‹œ์— ์ƒ์‚ฐํ•ด๋ณด๋ฉด

๊ฐ€์žฅ ์ฒ˜์Œ์— ๋ฌด์‹ํ•˜๊ฒŒ ์ž‘์„ฑํ•œ ์ฝ”๋“œ์™€ ๋™์ผํ•œ ๊ธฐ๋Šฅ์„ ์ž˜ ์‹คํ–‰ํ•ด์ฃผ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

ํ•˜์ง€๋งŒ ์ด ์ฝ”๋“œ์—์„œ๋„ ๋ฌธ์ œ์ ์ด ์žˆ๋Š”๋ฐ ์ฐจ๋Ÿ‰ ์ƒ์‚ฐ์„ ์š”์ฒญํ•˜๋Š” Client ์ฝ”๋“œ์—์„œ ๊ฐ๊ฐ์˜ Factory๋ฅผ ์ง์ ‘ ์ง€์ •ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค๋Š” ์ ์ด๋‹ค.

๐Ÿ“„ Client ์ฝ”๋“œ ์ˆ˜์ •

public class Client {
    public static void main(String[] args) {
        order(new AvanteFactoryV2(), "์ตœ์ค€ํ˜ธ", "white");
        order(new GV80FactoryV2(), "์ตœ์ค€ํ˜ธ", "black");
    }
    private static void order(CarFactory carFactory, String owner, String color){
        Car car = carFactory.orderCar(owner, color);
        System.out.println(car.toString());
    }
}

Client์˜ ์ฝ”๋“œ๊นŒ์ง€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๊ฒŒ ๋˜๋ฉด ์ค‘๋ณต๋˜๋Š” ์ฝ”๋“œ๋ฅผ ์—†์•ฐ๊ณผ ๋™์‹œ์— main์—์„œ๋Š” order์— ๋งž๋Š” factory์™€ ๊ตฌ๋งค์ž ์ •๋ณด๋งŒ ๋„˜๊ฒจ์ฃผ๋ฉด ๋˜๋Š” ์ฝ”๋“œ๋กœ ๋ฆฌํŒฉํ† ๋ง ๋œ๋‹ค.

๐Ÿ“„ ๋„ค๋น„๊ฒŒ์ด์…˜ ์ถ”๊ฐ€ํ•ด๋ณด๊ธฐ

public class Car {
    private String owner;
    private String name;
    private String color;
    private String logo;
    private String engine;
    private String navi;

    ...
}

๊ธฐ๋ณธ ๊ตฌ์กฐ๊ฐ€ ๋˜๋Š” Car class์— navi๋ฅผ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.

public interface CarFactory {
    
    ...
    
    private void settingCar(Car car, String owner, String color){
        car.setOwner(owner);
        car.setColor(color);
        car.setNavi("Kakao Navi");
    }
}

๊ทธ ํ›„์— ๋‚˜๋Š” settingCar() method์— navi๋ฅผ ์„ธํŒ…ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ˆ˜์ •ํ–ˆ๋‹ค.

๊ทธ๋Ÿผ ๊ฒฐ๊ณผ๋กœ ๋ชจ๋“  ์ฐจ๋Ÿ‰์— navigation์ด ์ถ”๊ฐ€๋œ๊ฒƒ์„ ํ™•์ธํ•ด๋ณผ ์ˆ˜ ์žˆ๋‹ค!

์ด๋ ‡๊ฒŒ ์ถ”๊ฐ€์ ์ธ ์‚ฌํ•ญ์ด ์ƒ๊ฒจ๋„ ๋””์ž์ธ ํŒจํ„ด์„ ์ ์šฉํ•ด๋‘๋‹ˆ ์ฝ”๋“œ์˜ ์ˆ˜์ •์ด ๋„ˆ๋ฌด ํŽธํ•ด์ง„๊ฒƒ์ด๋‹ค.

๐Ÿ“— ์ •๋ฆฌ

๐Ÿ“„ Factory Method Pattern์˜ ์žฅ์ ๊ณผ ๋‹จ์ 

์žฅ์  OCP๋ฅผ ์ง€ํ‚ค๋Š” ์ฝ”๋“œ๋ฅผ ์ƒ์‚ฐํ•ด๋‚ผ ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ factory์™€ product๊ฐ„์— ๋Š์Šจํ•œ ๊ฒฐํ•ฉ์„ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋‹ค.

๋‹จ์  ํ•„์š” class๋“ค์˜ ์ˆ˜๊ฐ€ ๋งŽ์•„์ ธ ๊ตฌ์กฐ๊ฐ€ ๋ณต์žกํ•ด์ง„๋‹ค.

๐Ÿ“„ OCP๋ž€?

Open Closed Principle์˜ ์ค„์ž„๋ง๋กœ ๋ณ€๊ฒฝ์— ๋‹ซํ˜€์žˆ๊ณ  ํ™•์žฅ์— ์—ด๋ ค์žˆ๋‹ค. ๋ผ๋Š” ์˜๋ฏธ์ด๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ์ ์šฉํ•œ ๋””์ž์ธ ํŒจํ„ด์—์„œ ๋ณด๋ฉด GV80์ด๋ผ๋Š” ํ™•์žฅ์—๋Š” ์—ด๋ ค ์žˆ์–ด ์‰ฝ๊ฒŒ ์ถ”๊ฐ€๊ฐ€ ๊ฐ€๋Šฅํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ ๊ธฐ์กด์˜ Avante๋ผ๋Š” ๊ธฐ๋Šฅ์—์„œ๋Š” ์ „ํ˜€ ์ฝ”๋“œ๊ฐ€ ์ˆ˜์ •๋˜๋Š” ๋ถ€๋ถ„์ด ์—†์ด ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ–ˆ์œผ๋ฏ€๋กœ ๋ณ€๊ฒฝ์—๋Š” ๋‹ซํ˜€์žˆ๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

๐Ÿ“„ interface์˜ default์™€ private method

๊ธฐ์กด์˜ interface์—์„œ๋Š” ์ถ”์ƒ ๋ฉ”์„œ๋“œ๋งŒ ์ •์˜๊ฐ€ ๊ฐ€๋Šฅํ–ˆ์—ˆ์ง€๋งŒ, java8์—์„œ Default method๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ๊ณ  java9์—์„œ๋Š” private method๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค.

default method๋Š” interface์—์„œ ๋ฏธ๋ฆฌ method์˜ ๊ธฐ๋Šฅ์„ ์ •์˜ํ•ด๋‘๊ณ  ์ƒ์†๋ฐ›์€ class์—์„œ๋„ ๊ธฐ๋Šฅ์„ ๋™์ผํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ๋” ๋งˆ์น˜ extendํ•œ๊ฒƒ๊ณผ ๋™์ผํ•˜๊ฒŒ ์ž‘๋™ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ์‰ฌ์šธ๊ฒƒ ๊ฐ™๋‹ค.

private mehtod๋Š” ๊ธฐ์กด interface๋Š” ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ๋ฅผ ์ •์˜ํ•  ์ˆ˜ ์—†์—ˆ์ง€๋งŒ java9๋ถ€ํ„ฐ๋Š” ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ๋ฅผ ์ •์˜ํ•˜์—ฌ default method์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋œ method์ด๋‹ค.

profile
ํ•ด๋‹น ์ฃผ์†Œ๋กœ ์ด์ „ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. https://ililil9482.tistory.com

0๊ฐœ์˜ ๋Œ“๊ธ€