Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why a controller helper?  RSS feed

 
william chaple
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does the constructor for the controller helper have three parameters when the controller helper only declares one member variable? What is the concept behind the code, is what I am trying to understand.
this is my code



 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 1st level answer is: because the constructor of the superclass HelperBase -which the ControllerHelper constructor calls- needs those 3 parameters.

The 2nd level answer is: because ControllerHelper uses those parameters - check its doGet method, which makes use of the request and response fields. It's not hard to imagine use cases that would use the servlet field as well.

The 3rd level answer is: because someone thought this kind of setup (which delegates servlet request handling to some other object) would be a good idea - which I think is debatable. If this is just a small part of a much larger web app, then its purpose may become clear by seeing the big picture. If this is all there is, then it's needlessly complicated IMO.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!