Java Reference
In-Depth Information
nextView = "error.jsp";
//finally redirect to correct view
RequestDispatcher requestDispatcher = request.getRequestDispatcher(nextView);
This controller was inefficient and promoted procedural programming. A new fea-
ture would inevitably add another if-else block. Now eInsure had thousands of use cases
with the underwriting module contributing a significant percentage of them. Hence, the
controller was bloated with a large number of if-else blocks. This controller showed all
the signs of the fat Magic Servlet antipattern (
AntiPattern ) and tried to perform too many tasks. It intercepted the requests, handled all
the different service requests, and finally forwarded the response to the browsers.
The controller was very large and soon ran beyond manageable proportions. The
development team then created a new controller named UnderwritingControllerNew.jsp
with a typical clone-and-modify programming style. This new controller too turned
bulky in no time, and again the same step was repeated, paving the way for yet another
“new” controller. The story was no different for other modules such as accounting,
claims, and so on. Each of them had several controllers handling a subset of the features
available in that module.
One of the prime goals of OO component-based application development is
reusability. But having too many JSP/servlet controllers only promotes procedural pro-
gramming and minimizes reusability. Also, having multiple points of entry into an
application makes it vulnerable to security threats. The copy-paste style of reuse seemed
easy but had only short-term benefits. Apparently it saved time, but any application fix
had to be rolled out at all duplicated points. Common services such as authorization
checks also need to be replicated across all controllers. For bug fixes and maintenance,
developers spent hours locating first the correct controller and then the appropriate
if-else block, as well as comprehending the legacy data structures and code flow. The
result was a strenuous development process and unnecessary effort wastage.
Search WWH ::

Custom Search