📕 book
-
5장 - 스프링 데이터 JPA를 이용한 조회 기능📕 book/도메인 주도 개발 시작하기 2023. 1. 5. 00:26
❓CQRS 💡 CQRS는 명령(Command) 모델과 조회(Query) 모델을 분리하는 패턴 명령 모델 : 상태를 변경하는 기능 구현할 때 사용 조회 모델 : 데이터를 조회하는 기능을 구현할 때 사용' 엔티티, 애그리거트, 지포지터리 등 모델은 주문 취소, 배송지 변경과 같은 상태를 변경할 때 사용한다. 즉, 도메인 모델은 명령 모델로 주로 사용된다. 반면에 정렬, 페이징, 검색 조건 지정과 같은 기능은 주문 목록, 상품 상세와 같은 조회 기능에 사용된다. 📌 검색을 위한 스펙 검색 조건이 고정되어 있고 단순하다면 특정 조건을 조회하는 기능을 만들면 된다. public interface OrderDataDao { Optional findById(OrderNo id); List findByOrderer(S..
-
4장 - 리포지터리와 모델 구현📕 book/도메인 주도 개발 시작하기 2023. 1. 2. 23:05
📌 JPA를 이용한 리포지터리 구현 모듈 위치 리포지터리 인터페이스는 애그리거트와 같이 도메인 영역에 속한다. 리포지터리를 구현한 클래스는 인프라스트럭처 영역에 속한다. 가능한 리포지터리 구현 클래스를 인프라스트럭처 영역에 위치시켜서 인프라스트럭처에 대한 의존을 낮춰야 한다. 리포지터리 기본 기능 구현 리포지터리가 제공하는 기본 기능 ID로 애그리거트 조회 애그리거트 저장 리포지터리 인터페이스 - OrderRepository public interface OrderRepository { Order findById(OrderNo no); void save(Order order); } 인터페이스는 애그리거트 루트를 기준으로 작성한다. 애그리거트 조회하는 기능의 이름을 지을때 널리 사용하는 규칙 - ‘find..
-
7장 - 람다와 스트림📕 book/이펙티브 자바 2022. 11. 7. 18:27
자바 8에서 함수형 인터페이스, 람다, 메서드 참조라는 개념이 추가되면서 함수 객체를 더 쉽게 만들 수 있게 되었다. 이와 함께 스트림 API까지 추가되어 데이터 원소의 시퀀스 처리를 라이브러리 차원에서 지원하기 시작했다. 📌 익명 클래스보다는 람다를 사용하라 JDK 1.1. 이전 예전에는 자바에서 함수 타입을 표현할 때 추상 메서드를 하나만 담은 인터페이스(드물게는 추상클래스)를 사용했다. 이런 인터페이스의 인스턴스를 함수 객체(function object)라고 한다. JDK 1.1 JDK 1.1이 등장하면서 함수 객체를 만드는 주요한 수단은 익명 클래스가 되었다. 문자열을 길이순으로 정렬하기 위한 비교 함수로 익명 클래스를 사용 Collections.sort(words, new Comparator()..
-
6장 - 열거타입과 애너테이션📕 book/이펙티브 자바 2022. 11. 4. 19:21
자바의 특수한 목적의 참조타입 두가지 클래스의 일종인 열거 타입(Enum) 인터페이스의 일종인 어노테이션(annotation) 📌 int 상수 대신 열거 타입을 사용하라 열거 타입은 일정 개수의 상수 값을 정의한 후, 그 외의 값은 허용하지 않는 타입이다. 자바에서 열거 타입을 지원하기 전에는 정수 상수를 한 묶음 선언해서 사용하곤 했다. public static final int APPPLE_FUJI = 0; public static final int APPLE_PIPPIN = 1; public static final int APPLE_GRANNY_SMITH = 2; public static final int ORANGE_NAVEL = 0; public static final int ORANGE_TEM..
-
3장 - 애그리거트📕 book/도메인 주도 개발 시작하기 2022. 11. 2. 16:05
⭐ 애그리거트 도메인 객체 모델이 복잡해지면 개별 구성요소 위주로 모델을 이해하게 되고 전반적인 구조나 큰 수준에서 도메인 간의 관계를 파악하기 어려워진다. 도메인 요소 간의 관계를 파악하기 어렵다는 것은 코드를 변경하고 확장하는 것이 어려워진다는 것을 의미 상위 수준에서 모델이 어떻게 엮여 있는지 알아야 전체 모델을 망가뜨리지 않으면서 추가 요구사항을 모델에 반영할 수 있는데, 세부적인 모델만 이해할 경우에는 코드 변경을 최대한 회피하는 쪽으로 요구사항을 협의하게 된다. 따라서, 복잡한 도메인을 이해하고 관리하기 쉬운 단위로 만들려면 상위 수준에서 모델을 조망할 수 있는 방법이 필요하다. → 애그리거트 관련된 객체를 하나의 군으로 묶음. 수 많은 객체를 애그리거트로 묶어서 바라보면 상위 수준에서 도메인..
-
5장 - 제네릭📕 book/이펙티브 자바 2022. 11. 1. 17:21
제네릭은 자바 5부터 사용할 수 있다. 제네릭을 지원하기 전에는 컬렉션에서 객체를 꺼낼 때마다 형변환을 해야 했다. 누군가 실수로 엉뚱한 타입의 객체를 넣어두면 런타임에 형변환 오류가 발생 ⇒ 제네릭을 사용해 컴파일 과정에서 차단하여 더 안전하고 명확한 프로그램을 만들자. 📌 로 타입은 사용하지 마라 클래스와 인터페이스 선언에 타입 매개변수(type parameter)가 쓰이면, 이를 제네릭 클래스 혹은 제네릭 인터페이스라고 한다. 제네릭 타입 (generic type) 제네릭 클래스와 제네릭 인터페이스를 통틀어 제네릭 타입이라 한다. 각각의 제네릭 타입은 일련의 매개변수화 타입 을 정의한다. ex) List 은 원소의 타입이 String인 리스트를 뜻하는 매개변수화 타입 String이 정규 타입 매개변..
-
4장 - 클래스와 인터페이스📕 book/이펙티브 자바 2022. 11. 1. 17:15
📌 클래스와 멤버의 접근 권한을 최소화하라 어설프게 설계된 컴포넌트, 잘 설계된 컴포넌트의 가장 큰 차이점 클래스 내부 데이터와 내부 구현 정보를 외부 컴포넌트로부터 얼마나 잘 숨겼느냐 잘 설계된 컴포넌트는 모든 내부 구현을 완벽히 숨겨, 구현과 API를 깔끔히 분리한다. 오직 API를 통해서만 다른 컴포넌트와 소통 서로의 내부 동작 방식에는 전혀 개의치 않는다. 정보 은닉, 캡슐화 장점 시스템 개발 속도를 높인다 시스템 관리 비용을 낮춘다 성능최적화에 도움을 준다. 소프트웨어 재사용성을 높인다 큰 시스템을 제작하는 난이도를 낮춘다. 접근 제어 메커니즘 자바는 정보 은닉을 위한 다양한 장치를 제공, 그중 하나가 접근 제어 메커니즘이다. 각 요소의 접근성은 그 요소가 선언된 위치와 접근 제한자로 정해진다...
-
2장 - 아키텍처 개요📕 book/도메인 주도 개발 시작하기 2022. 10. 27. 00:54
📌 네 개의 영역 아키텍처를 설계할 때의 전형적인 네 가지 영역 표현 응용 도메인 인프라스트럭처 표현 영역 (UI 영역) 사용자의 요청을 받아 응용 영역에 전달하고 응용 영역의 처리 결과를 다시 사용자에게 보여주는 역할 사용자의 요청을 해석해서 응용 서비스에 전달 응용 서비스의 실행 결과를 사용자가 이해할 수 있는 형식으로 변환하여 응답 웹 애플리케이션의 표현영역은 HTTP 요청을 응용 영역이 필요로 하는 형식으로 변환해서 응용 영역에 전달하고 응용 영역의 응답을 HTTP 응답으로 변환하여 전송 응용 영역 시스템이 사용자에게 제공해야 할 기능을 구현 응용 영역은 기능을 구현하기 위해 도메인 영역의 도메인 모델을 사용한다. 사용자에게 제공할 기능을 도메인 모델을 이용해서 구현 응용 서비스는 로직을 직접 수..