Skip to content

[토비의 스프링] 1.4.2_반복되는 메서드의 중복 제거 #64

@taxol1203

Description

@taxol1203

list 1_16에서 new DConnectionMaker()를 list 1_17과 같이 ConnectionMaker 구현 클래스의 인스턴스를 만드는 부분을 제거 하기 위해 ConnectionMaker 생성용 메서드를 이용하도록 수정하였습니다.

이는 성능의 개선 보다는, 유지 보수성을 좋게 하기 위해 다음과 같이 리펙토링 하였다고 이해하면 될까요?

public class DaoFactory {
	public UserDao userDao() {
		return new UserDao(connectionMaker());
	}
	public AccountDao accountDao() {
		return new AccountDao(connectionMaker());
	}
	public MessageDao messageDao() {
		return new MessageDao(connectionMaker());
	}
	public ConnectionMaker connectionMaker() {
		return new DConnectionMaker();
	}
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions