+ 2

What if i gave some other name as giveAge instead of getAge

26th Feb 2018, 11:45 AM
afzal
afzal - avatar
4 odpowiedzi
+ 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() 👍
26th Feb 2018, 12:13 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 5
Getters and setters? It would make no difference.
26th Feb 2018, 11:50 AM
Jacob Pembleton
Jacob Pembleton - avatar
+ 2
it will make no difference but using get and set as prefix in function names makes readability much easier....
26th Feb 2018, 12:11 PM
Franky BrainBox
Franky BrainBox - avatar
+ 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!
26th Feb 2018, 3:08 PM
D B
D B - avatar