I am reading through the Guava library, and I keep running into methods that look something like this:
@Override public int size() {
return size;
}
What is the difference (strategically, conventionally, etc) between the above and the following?
@Override public int getSize() {
return size;
}
Or is there no difference? Is it just shorthand?
One form isn't using JavaBeans conventions. Functionally speaking, systems that expect you to follow those conventions will not work or be very cumbersome to set up if you use non-conventional getters/setters for your beans, but if you're not, then there's no real difference.
Since Guava has a lot of collections, and the Collection
interface actually defines a size()
method, my gut tells me that Guava is more inclined to follow the Collection
interface than JavaBeans conventions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With