자기개.발
Gof 디자인 패턴(예습)
스마라그드
2020. 1. 28. 01:11
2020.01.26~27 동안 Y튜브에서 찾은 DP관련 영상을 보고 내가 작성한 프로젝트 문제점 파악하기.
1. Strategy Pattern
= 학원에서 이해하지 못했던 인터페이스와 상속을 배운 이유
MVC2 모델의 Service 단에서 주구장창~~~ 이유도 모르고~~~ 000Service + 000ServiceImpl 를 만들었다.
--기능의 선언과 구현의 분리--
//Service.java
@Service
public interface EventBoardService {
public int countEvent();
public List<ResultMap> selectEventList(CommunityVO boardVo, RowBounds rowBounds);
}
//ServiceImpl.java
@Service
public class EventBoardServiceImpl implements EventBoardService {
@Override
public int countEvent() {
return sqlSession.selectOne("eventDAO.countEvent");
}
@Override
public List<ResultMap> selectEventList(CommunityVO communityVo, RowBounds rowBounds) {
return sqlSession.selectList("eventDAO.selectEventList", communityVo, rowBounds);
}
}
//Controller.java
@Autowired
private EventBoardService eventBoardService;
...
...
@PostMapping(value = "/eventList")
public String eventList(Model model, HttpServletRequest, CommunityVO communityVo>{
...
...
int totalCount = eventBoardService.countEvent();
List<ResultMap> eventList = eventBoardService.selectEventList(communityVo,
new RowBounds(page.getStart(), page.getPageSize()));
...
...
return "돌아갈주소";
}
게시판의 경우에는 그 기능이 CRUD각각 하나씩이여서 크게 문제는 없었던것 같다.
하지만 다른 JAVA단에서 큰 문제가 발생하는데....