Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getters / Setters  RSS feed

 
Matt Elliott
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the performance impact of going through getters and setter methods as oppose to accessing the data directly?

I know this goes against style points in java, but I'm curious.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Negligible in the extreme.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Didn't someone just ask that? I seem to recall letting loose an extensive dissertation on why I've come to prefer mutators over direct field access within the last 2 weeks or so.

That viewpoint just got a healthy boost on mu latest project, BTW. It's code that came from elsewhere and it's a LOT easier to track down where stuff gets changed when mutators are used. Plus I added a decorator class, and mutators make it easier to manage the indirection.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!