August 8th, 2013, 07:13 PM
Help!! Do I really need to pass objects through methods???
I often come across the same problem while coding and was wondering how others get around it (if at all). The problem is when I need to pass information across multiple levels (usually 3 or more). For example, assuming a simple java servlet with a controller layer, a service layer and a dao layer. Now, suppose I want to pass an object which comes from the controller layer (maybe a User object from the Request) to the DAO layer. I usually end up having to pass the object through the Service layer even though the Service doesn't do anything with the object directly, it just passes it along to the DAO layer. Is there a pattern that would allow me to clean this up? It isn't about the specific case, I've also had this happen when refactoring a large method (breaking it up into smaller methods in the same class) and found this similar problem.
August 9th, 2013, 05:58 AM
Have you tried using a Session variable?