Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getters / Setters

 
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: 65535
108
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: 18419
60
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!