Spring & OOP
IoC/DI - ์ถ์ํ์ ์์กด์ฑ ์ฃผ์
public interface PaymentGateway {
void authorize(String orderId, long amount);
}
@Service
class TossPaymentsGateway implements PaymentGateway {
public void authorize(String orderId, long amount) { /* ... */ }
}
@Primary
@Service
class KakaoPayGateway implements PaymentGateway {
public void authorize(String orderId, long amount) { /* ... */ }
}
@Service
class PaymentService {
private final PaymentGateway gateway;
public PaymentService(@Qualifier("tossPaymentsGateway") PaymentGateway gateway) {
this.gateway = gateway;
}
}AOP - ๊ด์ฌ์ฌ ๋ถ๋ฆฌ
PSA(Portable Service Abstraction) - ์ผ๊ด๋ ์๋น์ค ์ถ์ํ
์ด๋ฒคํธ - ๋ชจ๋ ๊ฐ ๊ฒฐํฉ๋ ๊ฐ์
Last updated