"빈약한 도메인 모델"의 두 판 사이의 차이

7번째 줄: 7번째 줄:


==예시==
==예시==
{{소스|빈약함}}
{{소스헤더|빈약함}}
<source lang="csharp">
<source lang="csharp">
class Box {
class Box {
15번째 줄: 15번째 줄:
</source>
</source>


{{소스|빈약하지 않음}}
{{소스헤더|빈약하지 않음}}
<source lang="csharp">
<source lang="csharp">
class Box {
class Box {

2019년 2월 3일 (일) 02:48 판

1 개요

anemic domain model
빈약한 도메인 모델
  • 도메인 모델에 비즈니스적으로 유의미한 내용을 갖고 있지 않은 객체들
  • 비즈니스 로직(유효성 검사, 연산, 비즈니스 규칙 등)이 거의 없는 도메인 객체들이 있는 도메인 모델
  • 예: getter/setter만 있는 객체

2 예시

빈약함
class Box {
    public int Height { get; set; }
    public int Width { get; set; }
}
빈약하지 않음
class Box {
    public int Height { get; private set; }
    public int Width { get; private set; }

    public Box(int height, int width) {
        if (height <= 0) {
            throw new ArgumentOutOfRangeException(nameof(height));
        }
        if (width <= 0) {
            throw new ArgumentOutOfRangeException(nameof(width));
        }
        Height = height;
        Width = width;
    }
    public int area() {
       return Height * Width;
    }
}

3 같이 보기

4 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}