# 객체 지향 설계와 스프링

스프링은 다음 기술로 다형성 + OCP, DIP를 가능하게 지원한다.\
\- DI(Dependency Injection) : 의존관계, 의존성 주입\
\- DI 컨테이너 제공\
\&#xNAN;**=>클라이언트 코드 변경 없이 기능 확장**\
\=>쉽게 부품을 교체하듯이 개발할 수 있다!

모든 설계에 역할과 구현을 분리하자! - 자동차, 공연의 예를 떠올려보자.\
애플리케이션 설계도 공연을 설계하듯이 배역만 만들어두고, 배우는 언제든지 유연하게 변경할 수 있도록 만드는 것이 좋은 객체 지향 설계다.\
이상적으로는 모든 설계에 인터페이스를 부여하는 것이다!\
\=>DB를 선정하지 않았을 때에도 개발 진행할 수 있다.

하지만 인터페이스를 도입하면 추상화라는 비용이 발생한다.\
(코드가 추상화됨으로써 인터페이스를 보고, 구현체를 한번 더 봐야한다.)\
기능을 확장할 가능성이 없다면 구체 클래스를 직접 사용하고, 향후 꼭 필요할 때 리팩토링해서 인터페이스를 도입하는 것도 방법이다.(확장 가능성이 있다면 인터페이스로 구현!)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/spring/undefined-3/undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
