• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaBeans or Transfer Object?

 
Chris Bicnal
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

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...

Any ideas?

What's everyone else done?

Thanks,

Chris

PS Not that it matters, but I'm doing B&S...
 
David Winters Junior
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris,

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.

David
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic