|
|
|
|
|
by andallas
4008 days ago
|
|
I see this same issue come up from time to time and I always recall a little saying I heard (unfortunately I don't remember the source). "If you are having trouble naming something, then you don't fully understand that something." What I get from that saying is that if I have a function that I am struggling to name, it means that I don't fully understand the problem, and there's a good chance that it is doing to many things. Keep your functions to performing a single task, so they have just that one purpose, then name it after what it does. This improves readability and makes naming things much easier. You have a variable you can't name, well, what data is it actually holding? If it is holding more than one piece of data (reused) then you are doing something wrong or very hacky. Follow the same rule as with functions. Keep your variables to holding just one specific piece of data, and name it after that. Both of these rules not only make naming things much easier, I've found they produce much more readable code, easier to debug code, and generally much less bugs in the code. |
|