You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
그리고 한 가지 더 제안해보자면 member의 PhysicalAttributes를 그대로 사용하는 경우보다는 weight 값을 추출해서 사용하는 경우가 더 많을 것 같은데요,
그런데 현재 코드에서는 멤버의 weight 값을 추출하기 위해 객체의 내부 구조를 모두 알아야하는 상황으로 보여요. (디미터)
member.getPhysicalAttributes().getWeight(); // member + physicalAttributes 객체의 내부 구조를 모두 알아야 함
따라서 아래와 같이 weight에 대한 Getter를 추가하는 것은 어떻게 생각하시나요?
public double getWeight() {
if (physicalAttributes == null) {
throw new CommonException();
}
return physicalAttributes.weight();
}
member.getWeight();
PhysicalAttributes record로 변경
그리고 PhysicalAttributes는 의미상 vo로 보이는데 (= 성별과 무게가 같으면 동일한 신체 조건을 가진다) 클래스가 아닌 record로 정의하는건 어떤가요?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
member 엔티티에 getter 추가
그리고 한 가지 더 제안해보자면 member의 PhysicalAttributes를 그대로 사용하는 경우보다는 weight 값을 추출해서 사용하는 경우가 더 많을 것 같은데요,
그런데 현재 코드에서는 멤버의 weight 값을 추출하기 위해 객체의 내부 구조를 모두 알아야하는 상황으로 보여요. (디미터)
member.getPhysicalAttributes().getWeight(); // member + physicalAttributes 객체의 내부 구조를 모두 알아야 함
따라서 아래와 같이 weight에 대한 Getter를 추가하는 것은 어떻게 생각하시나요?
public double getWeight() {
if (physicalAttributes == null) {
throw new CommonException();
}
return physicalAttributes.weight();
}
member.getWeight();
PhysicalAttributes record로 변경
그리고 PhysicalAttributes는 의미상 vo로 보이는데 (= 성별과 무게가 같으면 동일한 신체 조건을 가진다) 클래스가 아닌 record로 정의하는건 어떤가요?
Beta Was this translation helpful? Give feedback.
All reactions