TIL
  • Contents
  • Book
    • 도메인 주도 설계
      • 1. 동작하는 도메인 모델 만들기
    • 오브젝트
      • 데이터 중심 설계
      • 책임 중심 설계
      • 책임 할당을 위한 GRASP 패턴
      • 메시지와 인터페이스
      • 객체 분해
    • Effective Java
      • Item 7 - 다 쓴 객체 참조를 해제하라
      • Item 7 발표 내용
      • Item 13 - clone 재정의는 주의해서 진행하라
      • Item 13 발표 내용
      • Item 16 - public 클래스에서는 public 필드가 아닌 접근자 메서드를 사용하라
      • Item 16 발표 내용
      • Item 26 - 로 타입은 사용하지 말라
      • Item 28 - 배열보다는 리스트를 사용하라
      • Item 28 발표 내용
      • Item 29 - 이왕이면 제네릭 타입으로 만들라
      • Item 30 - 이왕이면 제네릭 메서드로 만들라
      • Item 31 - 한정적 와일드 카드를 사용해 API 유연성을 높이라
      • Item 35 - ordinal 메서드 대신 인스턴스 필드를 사용하라
      • Item 37 - ordinal 인덱싱 대신 EnumMap을 사용하라
      • Item 37 발표 내용
      • Item 43 - 람다보다는 메서드 참조를 사용하라
      • Item 43 발표 정리
      • Item 56 - 공개된 API 요소에는 항상 문서화 주석을 작성하라
      • Item 56 발표 정리
      • Item 62 - 다른 타입이 적절하다면 문자열 사용을 피하라
      • Item 62 발표 정리
      • Item 73 - 추상화 수준에 맞는 예외를 던지라
      • Item 83 - 지연 초기화는 신중히 사용하라
      • Item 83 발표 내용
      • Item 89 - 인스턴스 수를 통제해야 한다면 readResolve보다는 열거 타입을 사용하라
      • Item 89 발표 내용
    • 개발자를 위한 SQL 튜닝
      • SQL 쿼리 실습을 위한 DB 서버 구축
      • 인덱스 튜닝
      • 인덱스 스캔 튜닝
      • 인덱스 스캔 튜닝 실습
      • 인덱스 패스트 풀 스캔
      • 테이블 풀 스캔 튜닝
      • 조인 튜닝
      • 중첩 루프 조인 튜닝
      • 중첩 루프 조인 튜닝 실습
      • 해시 조인 튜닝
      • 해시 조인 튜닝 실습
      • 세미 조인 튜닝
      • 세미 조인 튜닝 실습
      • 아우터 조인
      • 함수 튜닝
      • 부분 범위 처리 튜닝
      • 파티셔닝 튜닝
      • 파티션 인덱스 튜닝
      • 병렬 처리 튜닝
  • Java
    • Design Pattern
      • Intro
      • Types of Design Patterns
      • Creational
        • Builder Pattern
        • Singleton Pattern
        • Prototype Pattern
        • Factory Pattern
        • Abstract Factory Pattern
      • Structural
        • Adapter Pattern
        • Bridge Pattern
        • Composite Pattern
        • Decorator Pattern
        • Facade Pattern
        • Flyweight Pattern
        • Proxy Pattern
      • Behavioural
        • Chain of Responsibility Pattern
        • Command Pattern
        • Interpreter Pattern
        • Iterator Pattern
        • Mediator Pattern
        • Memento Pattern
        • Observer Pattern
        • State Pattern
        • Strategy Pattern
        • Template Method Pattern
        • Visitor Pattern
    • Java
      • Cracking the Coding Interview
      • TDD, Clean Code with Java 11기
        • 자동차 레이싱
        • 로또
        • 사다리 타기
        • 볼링 게임 점수판
    • 궁금증
      • 자바 8 버전의 인터페이스와 추상클래스
      • 자바의 제네릭은 어떻게 이전 버전과 호환되는 걸까?
      • 스프링 MVC 기본 구조
      • 마샬링과 직렬화
      • 인터뷰 질문 모음
      • Code Coverage
  • Database
    • Database
      • SQL 레벨업
      • DB 스터디
        • DBMS
          • MySQL
        • INDEX
        • Join(Nested Loop, Hash)
        • Join(Semi, Outer)
        • Partial Range Processing
        • Function
        • Partitioning
        • Parallel Processing
  • Network
  • Architecture
    • Issue
      • Git Push Error
      • SonarLint Warning - assertThatExceptionOfType()
  • Infra
  • Spring
    • Spring JPA
      • 1. 데이터 모델링 및 연관관계 설정
      • 2. 최적화 내용
      • 3. Spring-Data-Jpa
      • 4. Query DSL
    • Spring Security
      • Intro
    • Spring Batch
      • 배치용 디비 설치
      • 배치 데이터 분석하기
      • 배치 프로세스 구상하기 및 성능 차이 확인하기
  • Issue
  • Tistory
    • Tistory Blog
  • Design High Performing Architectures
  • Design Resilient Architectures
  • Design Secure Applications And Architectures
  • Design Cost-Optimized Architectures
Powered by GitBook
On this page
  • 객체 지향
  • 자동차 경주
  • 로또
  • 사다리 타기
  • 볼링 게임 점수판

Was this helpful?

  1. Java
  2. Java

TDD, Clean Code with Java 11기

PreviousCracking the Coding InterviewNext자동차 레이싱

Last updated 3 years ago

Was this helpful?

개발 습관 개선을 위한 학습

객체 지향

GRASP

  • GRASP - General Responsibility Assignment Software Patterns

  • 책임 기반 객체지향 관점에서 객체에 책임을 할당하기 위한 패턴을 정리한 것을 의미

  • : applying uml and patterns 책의 GRASP 설명 정리한 내용

  • : GRASP을 잘 설명하고 있는 영어로 된 문서

  • Information Expert

    • 역할을 수행할 수 있는 정보를 가지고 있는 객체에 역할을 부여하자.

    • Problem: What is a basic principle by which to assign responsibilities to objects?

    • Solution: Assign a responsibility to the class that has the information needed to fulfill it.

  • Creator

    • 객체의 생성은 생성되는 객체의 컨텍스트를 알고 있는 다른 객체가 있다면, 컨텍스트를 알고 있는 객체에 부여하자.

    • Problem: Who creates object A?

    • Solution: Assign class B the responsibility to create object A if one of these is true (more is better)

      • B contains or compositely aggregates A

      • B records A

      • B closely uses A

      • B has the initializing data for A

  • Controller

    • 시스템 이벤트(사용자의 요청)를 처리할 객체를 만들자. 시스템, 서브시스템으로 들어오는 외부 요청을 처리하는 객체를 만들어 사용하라.

    • Problem: What first object beyond the UI layer receives and coordinates “controls” a system operation?

    • Solution: Assign the responsibility to an object representing one of these choices:

    • Represents the overall “system”, “root object”, device that the software is running within, or a major

      subsystem (these are all variations of a facade controller)

    • Represents a use case scenario within which the system operation occurs (a use case or session controller)

  • Low Coupling

    • 객체들간, 서브 시스템들간의 상호의존도가 낮게 역할을 부여하자.

    • Problem: How to reduce the impact of change? How to support low dependency and increased reuse?

    • Solution: Assign responsibilities so that (unnecessary) coupling remains low. Use this principle to evaluate

      alternatives.

  • High Cohesion

    • 각 객체가 밀접하게 연관된 역할들만 가지도록 역할을 부여하자.

    • Problem: How to keep objects focused, understandable, manageable and as a side effect support Low Coupling?

    • Solution: Assign a responsibility so that cohesion remains high. Use this to evaluate alternatives.

  • Indirection

    • 두 객체 사이의 직접적인 Coupling을 피하고 싶으면, 그 사이에 다른 객체를 사용하라.

    • Problem: Where to assign a responsibility to avoid direct coupling between two or more things?

    • Solution: Assign the responsibility to an intermediate object to mediate between other components or services

      so that they are not directly coupled.

  • Polymorphism

    • 객체의 종류에 따라 행동양식이 바뀐다면, Polymorphism 기능을 사용하자.

    • Problem: How handle alternatives based on type?

    • Solution: When related alternatives or behaviors vary by type (class), assingn responsibility for the

      behavior (using polymorphi operations) to the types for which the behavior varies.

  • Pure Fabrication

    • Information Expert 패턴을 적용하면 Low Coupling과 High Cohesion의 원칙이 깨어진다면, 기능적인 역할을 별도로 한 곳으로 모으자.

    • Problem: What object should have the responsibility, when you do not want to viloate High Cohesion and Low

      Coupling but solutions offered by other principles are not appopriate?

    • Solution: Assign a highly cohesive set of responsibilites to an artifical or convenience class that does not

      represent a problem domain conecept.

  • Protected Variations

    • 변경될 여지가 있는 곳에 안정된 인터페이스를 정의해서 사용하자.

    • Problem: How to design objects, subsystems and systems so that the variations or instability in these

      elements does not have an undesirable impact on other elements?

    • Solution: Identify points of predicted variation or instability, assign responsibilities to create a stable

      interface around them.

객체지향 5원칙(SOLID)

  • SRP (단일책임의 원칙: Single Responsibility Principle)

    • 작성된 클래스는 하나의 기능만 가지며 클래스가 제공하는 모든 서비스는 그 하나의 책임(변화의 축: axis of change)을 수행하는 데 집중되어 있어야 한다

  • OCP (개방폐쇄의 원칙: Open Close Principle)

    • 소프트웨어의 구성요소(컴포넌트, 클래스, 모듈, 함수)는 확장에는 열려있고, 변경에는 닫혀있어야 한다.

  • LSP (리스코브 치환의 원칙: The Liskov Substitution Principle)

    • 서브 타입은 언제나 기반 타입으로 교체할 수 있어야 한다. 즉, 서브 타입은 언제나 기반 타입과 호환될 수 있어야 한다.

  • ISP (인터페이스 분리의 원칙: Interface Segregation Principle)

    • 한 클래스는 자신이 사용하지 않는 인터페이스는 구현하지 말아야 한다.

  • DIP (의존성역전의 원칙: Dependency Inversion Principle)

    • 구조적 디자인에서 발생하던 하위 레벨 모듈의 변경이 상위 레벨 모듈의 변경을 요구하는 위계관계를 끊는 의미의 역전 원칙이다.

자동차 경주

로또

사다리 타기

볼링 게임 점수판

책임할당에 기반한 객체 설계 원칙
GRASP
racingCar
lotto
ladder
bowling