인터페이스
-
Rest API 설계 기본 팁 : 계층 구조에 대한 식별자를 명확히 하기개발 나누고 더하기/기타 2023. 7. 25. 22:28
시스템을 설계하다보면 1:1 또는 1:N 관계로 계층 모델이 많이 나온다. 이커머스를 예로 들면 상품과 하위 아이템인 경우인데, 상품에 상품명(PSG 이강인 티셔츠), 상세 설명(상세 이미지)와 같은 정보를 담고, 이 상품을 참조하는 아이템에는 사이즈(S, M, L)와 재고 등을 담는 구조이다. 백오피스 같은 관리 시스템에서 상품과 아이템별로 관리해야 하는 요구가 있다고 치자. 이를 조회하는 API 스펙은 대충 다음과 같이 나올 수 있다. 상품 조회 API url : {host}/api/v1/goods/{id} method : GET param : id - 상품 ID response : name - 상품명, description - 상세 설명 아이템 조회 API url : {host}/api/v1/goo..
-
오브젝트 4 - 메세지, 인터페이스, 의존성책책책 책을 읽읍시다/프로그래밍 2023. 2. 13. 23:21
퍼블릭 인터페이스와 오퍼레이션 객체가 의사소통을 위해 외부에 공개하는 메세지의 집합을 퍼블릭 인터페이스라고 부른다. 프록래밍 언어의 관점에서 퍼블릭 인터페이스에 포함된 메세지를 오퍼레이션(operation)이라고 부른다. 오퍼레이션은 수행 가능한 어떤 행동에 대한 추상화다. 흔히 오퍼레이션이라고 부를 때는 내부의 구현 코드는 제외하고 단순히 메세지와 관련된 시그니처를 가리키는 경우가 대부분이다. 영화 예매 시스템의 예로 DiscountCondition 인터페이스에 정의된 isSatisfiedBy가 오퍼레이션에 해당한다. public interface DiscountCondition { boolean isSatisfiedBy(Screening screening); } 그에 비해 메세지를 수신했을 때 실제로..
-
오브젝트 1 - 맛보기책책책 책을 읽읍시다/프로그래밍 2023. 2. 7. 22:38
저자 : 조영호 책 이모저모 객체지향 개발의 교과서이다. Java, C# 등 객체지향 언어를 다루는 개발자라면 필독해야 하는 도서이다. '토비의 스프링'을 읽었을 때와 같은 감동을 받았다. 이 책의 핵심은 "퍼블릭 인터페이스를 통해 캡슐화된 자율적인 객체들이 메세지를 주고 받으며 협력하는 코드를 설계하라"이다. 이를 다양한 코드 리팩터링 사례를 보여주면서 유연한 시스템이 어떻게 만들어지는지 설명해주는데 읽으면서 참 잘 와닿았다. 쉽게 전달이 되면서도 그렇다고 가볍지는 않고 고도의 전문 지식을 바탕으로 근거를 제시하니 읽으면서 남는게 많은 느낌이 든다. 저자의 전작인 '객체지향의 사실과 오해'는 말 그대로 객체지향의 해묵은 오해를 깨는 도끼였다면, 이번 저서는 깨진 자리에 새살을 돋게하는 영양제 같은 책이..