+ 3
When would you say a function() name is too long?
As Iâm learning more and more each day, one common trend I am noticing is that some of my function names are long. I.E - GetUserInfoByComboBox(); As a function name it seems straight forward, but would you consider this too long? I went back and changed it to just GetUser() which works fine in this case, but sometimes in other situations I feel like it isnât descriptive enough and Iâm having to go double check comments. What do you guys think? Or is this an example of bad software design?
3 Answers
+ 11
I think that is better to use longer names if you better understanding then and that is most important...
+ 4
you usually name a function what it does so its simple for readers to understand it better but you dont want to make it so long its a annoying to type out
+ 2
I try to keep variable names and method names as short as possible and as descriptive as possible.
I do not use abbrevations
a variable name should only contain a noun
a method name should have verb and a noun
So a variable can be "User"
A method name can be "GetUser"
So a variable can be "UserInfo"
A method name can be "GetUserInfo"
I try to avoid GetUserInfoByComboBox, because I do not want my method to be depend on User interface elements.