• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

setter/getter in bean - overengineering?

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have seen many bean classes like above which has private variables and getter/setter for encapsulation.

My question is that isin't this too much over engineering? Would it not be better to just have the class with the properties declared as public (assuming that the class has no behaviours/methods and the setter/getter do not perform any validation or any other operation on the data)

Cheers-
Joshua
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So that when getter/setter logic *does* change, so must all your code?

The issue isn't "over-engineering", it's Java's lack of real properties.
 
Joshua Antony
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never seen some of the DTO change (in one of the maintanance project ) and do not feel like that may change in future too, so in that case would it not be appropriate to choose data structure over OOP
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Java had real properties, sure. But it doesn't, and things *do* change, frequently.

Plus most libraries *expect* things to be JavaBeans; making things *not* JavaBeans would negate the value of a lot of already-written code.
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic