Being from a J2EE background I've architected my application in a tiered manner (GUI, business and data).
Each layer communicates to the one below via an interface I've defined (so there are two interfaces in total).
In all methods I only pass one parameter as I'm employing the transfer object pattern, but I have a question about that....
Should I pass objects between my methods that are JavaBeans (with getters and setters for every field) or is a POJO with publicly exposed attributes OK?
The reason I ask is that's it's a pain calling the get and set each time you want to get or set a value and I think it makes the code more difficult to read. But I'm concerned if I omit the getters and setters I could get marked down for not encapsulating my data...
What's everyone else done?
PS Not that it matters, but I'm doing B&S...
David Winters Junior
posted 8 years ago
I use a getter/setter method on each of the attributes like a JavaBean class definition. It is good practice defining private attributes and public methods to access those attributes therefore using encapsulation which im sure you know all about.