You need to sign in to do that
Don't have an account?

getVariable methods
Hi,
I'm just starting with VisualForce (though I'm familiar with Apex), and I just was wondering about this aspect of VF code (easy solve and kudos for whoever wants on this one!).
So when I create a "getter" method in apex, I just reference that by omitting the "get" part of the name. like:
public string getSomething
can be referenced by
{!something} .
I guess this makes it easier to write getter methods, my question is,
is this a common functionality within other programming languages? Or is it just for Salesforce?
Or what is the reason behind omitting the "get" part of the method, why does SalesForce not require it?
I don't know why something so easy has me confused. Myabe it's a dumb question but if you can understand at all why I'm confused and want to help me out I'll appreciate it!!
thanks
Yes, other languages have this. I think that APEX picked it up from java.
Here is a link that can explain why these accessor methods are being used.
Here is the main content:
An 'accessor' method is a method that is usually small, simple and provides the sole means for the state of an object to be accessed (retrieved) from other parts of a program.
Although this introduces a new dependency, as stated above, use of methods is preferred, in the object-oriented paradigm, to directly accessing state data - because those methods provide an abstraction layer.
For example, if a bank-account class provides a getBalance() accessor method to retrieve the current balance (rather than directly accessing the balance data fields), then later revisions of the same code can implement a more complex mechanism for balance retrieval (say, a database fetch), without the dependent code needing to be changed . . .