Builder Pattern
·
Backend/Spring Boot
1. 빌더 패턴 탄생 배경빌더 패턴이 왜 필요한지 이해하려면 그 이전의 객체 생성 방식들의 문제점을 먼저 알아야 합니다.1-1. 점층적 생성자 패턴 (Telescoping Constructor Pattern)필드가 많은 객체를 생성할 때, 필수 파라미터만 받는 생성자부터 모든 파라미터를 받는 생성자까지 여러 개를 오버로딩으로 쌓아올리는 방식입니다.class NutritionFacts { private final int servingSize; // 필수 private final int servings; // 필수 private final int calories; // 선택 private final int fat; // 선택 private f..
DAO, DTO, VO, Entity
·
Backend/Spring Boot
DTO vs DAO vs VO vs Entity — 완전 비교 가이드1. 한눈에 보는 개요DTO DAO VO Entity풀네임Data Transfer ObjectData Access ObjectValue ObjectEntity역할계층 간 데이터 전달DB 접근 추상화값 자체를 표현도메인 식별 단위패턴 출처Fowler, EAAGoF, J2EEFowler, DDDDDD (Evans)식별자(ID)없어도 됨해당 없음없음반드시 있음불변성권장해당 없음필수가변 허용비즈니스 로직없음DB 쿼리없음(순수 값)있어야 함동등성 기준보통 참조해당 없음값IDSpring 계층Controller ↔ ServiceRepository 구현Domain 내부Domain / DB2. 각각의 상세 분석2-1. DTO (Data Transfer ..
Bean Scope
·
Backend/Spring Boot
Bean Scope 완전 정복Scope가 뭔가요?Scope = "이 객체를 얼마나 오래, 어디까지 공유할 것인가"비유: 카페의 컵싱글톤 = 카페 전체에서 컵 1개 공유 (모두가 같은 컵 사용)프로토타입 = 손님마다 새 컵 제공request = 한 번 주문할 때마다 새 컵session = 한 손님이 앉아있는 동안 같은 컵 사용각 Scope 상세 설명1. Singleton (기본값)@Service // 기본이 singleton// @Scope("singleton") 생략 가능public class OrderService { private int orderCount = 0; // ⚠️ 위험한 코드 (아래 설명)}앱 시작 ↓Spring: "OrderService 딱 1개만 만들게" ↓컨테이너에 보관..
SpringBoot 내부동작
·
Backend/Spring Boot
Spring Boot 내부 동작 정리1. IoC / DI (제어의 역전 / 의존성 주입)IoC (Inversion of Control)전통적인 방식에서는 개발자가 직접 객체를 생성하고 관리했습니다.// 전통 방식 - 개발자가 직접 객체 생성 및 제어public class OrderService { private PaymentService paymentService = new PaymentService(); // 직접 생성 // 선언 + 할당까지}IoC는 이 제어권을 Spring 컨테이너에게 넘기는 것입니다.// IoC 방식 - Spring이 제어@Servicepublic class OrderService { private final PaymentService paymentService; ..
[Spring Boot] 공식문서 번역 - RESTful 웹 빌드하기
·
Backend/Spring Boot
https://spring.io/guides/gs/rest-service Getting Started | Building a RESTful Web ServiceIn Spring’s approach to building RESTful web services, HTTP requests are handled by a controller. These components are identified by the @RestController annotation, and the GreetingController shown in the following listing (from src/main/java/com/examplespring.io 이 글은 Spring의 공식 문서를 바탕으로 작성된 번역본입니다. Spring에서..
[Spring Boot] 스프링을 처음할때 보기 좋은 공식문서 순서
·
Backend/Spring Boot
https://spring.io/guides Spring | GuidesWhatever you're building, these guides are designed to get you productive as quickly as possible – using the latest Spring project releases and techniques as recommended by the Spring team.spring.io 스프링, 스프링부트는 공식문서가 저엉말 잘 되어 있다. 공식문서만 봐도 공부가 가능할 정도로.원하는 카테고리를 선택하여 편하게 골라보면 된다 처음 Spring Boot 할 때 보기 좋은 순 1.https://spring.io/guides/gs/rest-service Getting St..