Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactoring] 컬렉션 캡슐화 #128

Open
Dokyeongyun opened this issue Jan 24, 2022 · 0 comments
Open

[Refactoring] 컬렉션 캡슐화 #128

Dokyeongyun opened this issue Jan 24, 2022 · 0 comments
Labels
Enhancement New feature or request Refactoring

Comments

@Dokyeongyun
Copy link
Owner

컬렉션을 getter를 통해 제공하는 경우,
컬렉션 내의 원소 변경에 대해 캡슐화를 보장할 수 없다.

  1. 컬렉션 게터를 통해 원본 컬렉션을 반환하지 않도록 하거나,
    (컬렉션 게터가 아닌 중간 메서드를 하나 더 생성)
    ex) A.collections.add(1) → A.addToCollections(1)
  • 컬렉션 파이프라인의 사용을 제한할 수 있는 방법이다.
  1. 읽기전용 프록시를 반환하도록 한다.
    (쓰기 연산 시도 시, 예외 발생시키기)

어떤 경우를 선택하던, 코드 베이스 내에서 일관성을 지키도록 하자

@Dokyeongyun Dokyeongyun added Enhancement New feature or request Refactoring labels Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Refactoring
Projects
None yet
Development

No branches or pull requests

1 participant