Choosing good names
marcelo-cure.blogspot.com
Choosing good names
1–10 of 41 posts
Re: Choosing good names
#2This would allow you to ensure only valid values are passed and would help avoid problematic floating point arithmetic :)
Re: Choosing good names
#3I am never sure how much to abbreviate a name, but I guess if it's not going to be used much it can be long without problems.
Re: Choosing good names
#4Re: Choosing good names
#5You could provide even more clarity by using meaningful types like Money or TaxPercentage instead of Double. This would allow you to ensure only valid values are passed and would help avoid problematic floating point arithmetic :)
Re: Choosing good names
#6I guess the verbosity of the method's name is actually good in this case? Since it makes the function so much clearer. I am never sure how much to abbreviate a name, but I guess if it's not going to be used much it can be long without problems.
Re: Choosing good names
#7If you think about it, elegance and brevity in naming serve no logical purpose. When reading names, understandability is the only goal; elegance and brevity do not assist in this goal. Thus, from a readability standpoint, it is better for names to be verbose and informative at the expense of elegance.
There are those out there that complain about how verbosity contributes to increased typing time and the probability of spelling errors, to which I have to say: Modern dev tools like Intellisense and autocomplete largely eliminate this type of error. Additionally, if you hate these modern tools, I still feel that, especially in extremely large and complex code bases, the benefits of writing clear and understandable code with verbose naming far outweigh the benefits one gains when using brevity in naming.
Re: Choosing good names
#8I guess the verbosity of the method's name is actually good in this case? Since it makes the function so much clearer. I am never sure how much to abbreviate a name, but I guess if it's not going to be used much it can be long without problems.
Re: Choosing good names
#9I guess the verbosity of the method's name is actually good in this case? Since it makes the function so much clearer. I am never sure how much to abbreviate a name, but I guess if it's not going to be used much it can be long without problems.
If you're using a modern IDE, you shouldn't have to ever type the name out after the first time. I almost never abbreviate anything.
After that, I stopped giving a shit about how long my identifier names are and just make sure they explain in a direct (but concise!) way what that method does or what that variable is.
Re: Choosing good names
#10You could provide even more clarity by using meaningful types like Money or TaxPercentage instead of Double. This would allow you to ensure only valid values are passed and would help avoid problematic floating point arithmetic :)
I recently came across a codebase that implement type classes for almost all types of things it handles and found that to be overkill. Almost always, name and age can be represented by a string and an integer respectively; separate Name and Age classes just reduce the readability in your code.