[Refactoring] 객체 통째로 넘기기


[Refactoring] 객체 통째로 넘기기

여러 파라미터가 있는 경우 -> 한 개의 오브젝트, 레코드일 때, 객체를 통째로 넘겨서 파라미터를 줄일 수 있다. 이건 오브젝트가 있는 경우 사용한다. 이 리팩토링을 사용하기 전에 의존성을 고려해야 한다. 메서드의 위치가 적절하지 않을 수 있다. 객체 통째로 넘기기 package me.whiteship.refactoring._03_long_function._09_preserve_whole_object; import java.util.HashMap; import java.util.Map; public record Participant(String username, Map<Integer, Boolean> homework) { public Participant(String username) { this(username, new HashMap<>()); } public void setHomeworkDone(int index) { this.homework.put(index, true); } ...


#리팩토링 #백기선 #인프런

원문링크 : [Refactoring] 객체 통째로 넘기기