I am a bit funny when it comes to learning technology, I read about it away from the computer, because otherwise there would be a lot of stuff that I would be doing that would interfer with the process of actually reading a book. Anyway, I am reading Agile Java Development right now, and I got to the point where the author shows how to build a simple page.
The sheer amount of steps required is scaring me. What is more worrying is that the author keeps saying how simple this is compare to other approaches (which I presume Java guys would be familiar with). I keep comparing it to MonoRail + Windsor, and I can't believe that this is so complex.
From an architecture point of view, it is very separated, but from an implementation point of view, it looks messy. Here is the piece of code that caused this post. It is meant to put the current object for the request in the context:
{
if (request.getParameter(TID) != null
&& request.getParameter(TID).trim().length() > 0)
return timesheetManager.getTimesheet(Integer.parseInt(request
.getParameter(TID)), false);
Timesheet timesheet = new Timesheet();
Employee employee = (Employee) applicationSecurityManager
.getEmployee(request);
timesheet.setEmployeeId(employee.getEmployeeId());
timesheet.setStatusCode("P");
timesheet.setPeriodEndingDate(DateUtil.getCurrentPeriodEndingDate());
return timesheet;
}
I am not a Java guy, and I never did anything beyond an applet in Java, so I may be missing something, but is this considered to be a good form of writing your code?
Issuses that I have with the code:
- Dealing directly with the request, extracting inputs, going to the database, etc. Those are infrastructure style stuff (and fairly repetitive, I would imagine). I want my controller to deal with business use case.
- The whole model seems to be based on overriding specific methods calls, while I appriciate the design, to me it seems like it unnecessarily complicating things by moving related functionality to separate methods, when it could be in the same place. (The timesheet object returned from this method is passed to another method down the line, for instance.)
Am I missing something?
(Hm, angering the Java people, angering the P&P people, all I have left now is to anger the Ruby guys and I am set. I shouldn't worry about that, I have a safe place to hide, Cell #6.)