+ 2
What if i gave some other name as giveAge instead of getAge
4 Respuestas
+ 11
thats totally your wish that what name you want to give to a method , U can give it name "setName()" also , but the only thing is ... the function must be of setAge() 👍
+ 5
Getters and setters? It would make no difference.
+ 2
it will make no difference but using get and set as prefix in function names makes readability much easier....
+ 1
You could also name it POTATO().
-> A method's name does never ever affect it's functionality! (At least in most common languages, propably there are weird ones where they do...) <-
But: Conventions. And despite it would be funny, It makes your code so hard to maintain if you swap getValue and setValue!! Don't!