While analyzing an existing web application, you observe the following issues in the source code:
Duplicate control code is scattered throughout various view.
Business and presentation logic are mixed within these view.
The next phase of the project involves refactoring the existing code to address these two issues.
Which design pattern, if employed in the refactoring exercise, would most directly address the two
issues?
A.
Service to Worker
B.
Dispatcher view
C.
DAO
D.
Composite View
Explanation:
http://www.vincehuston.org/j2ee/corepatterns.html (see ‘service to worker’)
A
A
A is correct answer.
Two Problem :
Duplicate control code is scattered throughout various view. – Modularity is missing.
Business and presentation logic are mixed within these view. – Centralized control is missing and maintainability issue as logic spread over multiple views.
Explanation :
Service to worker used for Centralizes control and improves Modulatiry, reusability, and maintainability.
Dispatcher view is not correct answer because it will used when limited or zero business processing involved.
Use Dispatcher View with views as the initial access point for a request. Business processing, if necessary in limited form, is managed by the views.