6. REST
In 2000, Roy Fielding proposed Representational State Transfer (REST)
as an architectural approach to designing web services. REST is an
architectural style for building distributed systems based on
hypermedia.
If a POST method creates a new resource, it returns HTTP status code
201 (Created). The URI of the new resource is included in the Location
header of the response. The response body contains a representation
of the resource.
https://docs.microsoft.com/en-us/azure/architecture/best-practices/api-design
9. REST 증후군
public class Comment
{
public int Id { get; set; }
public int AuthorId { get; set; }
public string Content { get; set; }
}
public class User
{
public int Id { get; set; }
public string Username { get; set; }
public string PasswordHash { get; set; }
}
10. REST 증후군
public class CommentDto
{
public int Id { get; set; }
public UserDto Author { get; set; }
public string Content { get; set; }
}
public class UserDto
{
public int Id { get; set; }
public string Username { get; set; }
}
19. CQRS
• Command Query Responsibility Segregation
• Greg Young
• 명령과 조회는 각각 책임
• 𝑚 × 𝑛 → 𝑚 + 𝑛
CQRS is a very simple
pattern that enables
many opportunities for
architecture that may
otherwise not exist.
28. GUID와 관계형 데이터베이스
• 4 bytes vs. 16 bytes
• "Disk space is cheap."
• "That’s not the point."
• Fragmentation
• GUID Primary Key + Clustered Index on Sequential Key
30. 도메인 모델과 DTO(Data Transfer Object)
• 매핑은 고통
• 도메인 모델과 DTO는 각각 목적과 형태가 다름
31. 도메인 주도 설계와 CQRS
명령 측(Command-Side) 책임
• 도메인 모델
• 구조
• 규칙
• 활동
• 불변식(Invariants)
• 무결성(Integrity)
• 정규화(Normalization)
조회 측(Query-Side) 책임
• 뷰 상태 모델
• 성능
• 활용
• 규모 확장
32. DDD와 CQRS 조합 사례
Date Date Date Date Date Date Date Date Date Date
Room Type
Room Type
Rate Plan
Rate Plan
Rate Plan
Channel
Channel
Channel
Channel
33. Key-Value Store
DDD와 CQRS 조합 사례
명령 모델 조회 모델
Aggregate Root
Aggregate Root
Entity
Value Object
Entity
Entity
Entity
Entity
Page Page Page Page
Page Page Page Page