The following article has influenced my naming choices ever since I first read it: https://www.joelonsoftware.com/2005/05/11/making-wrong-code-...
How Developers Choose Names
141–150 of 157 posts
Re: How Developers Choose Names
#142I just use a UUID for every variable name to make sure the codebase never has any ambiguity. No one is going to confuse e7693160-b5cf-4761-9202-de019cfd0fc9 with c3d8b9ac-d0da-4bbc-912b-025ce4e47f62
That was not fun.
Re: How Developers Choose Names
#143The following article has influenced my naming choices ever since I first read it: https://www.joelonsoftware.com/2005/05/11/making-wrong-code-...
Re: How Developers Choose Names
#144I just use a UUID for every variable name to make sure the codebase never has any ambiguity. No one is going to confuse e7693160-b5cf-4761-9202-de019cfd0fc9 with c3d8b9ac-d0da-4bbc-912b-025ce4e47f62
A good name has maximal information density. If the string is compressible, you're wasting your reader's time. That's why I use all utf-8 glyphs to render my uniformly random and highly informative (from an information theory standpoint) variable names.
Re: How Developers Choose Names
#145As a non native english speaker I have a recurring problem with this: > getInstances(); // ok, returns an array of instances > getInstanceId(); // ok, returns an id > getInstancesId(); // ??, returns an array of id > get InstancesIds(); // ?? returns an array of id > getIdsOfInstances(); // ?? returns an array of id > getAllInstancesId(); // ?? returns an array of id > getAllInstancesIds(); // ?? returns an array of…
I have never understood the practice of using a verb phrase ("get") for functions with no side-effects. To me it makes more sense to name the function after the result, i.e. Instances , InstanceIds , AllInstanceIds etc.
So FetchInstances() is expensive (each time it's called) but the property Instances is cheaper or only expensive on the first access.
Re: How Developers Choose Names
#146With naming what IMO matters more than choosing one name, is choosing a name that is consistent with other similar names in the codebase. A new developer will learn your project's specific convention in a few minutes, but will be completely lost if the convention is routinely violated here and there. This is especially important with what verbs to use in methods, and how to name interfaces/classes in a way that respe…
Naming gets far worse than that. I've worked on code where the naming was not just unhelpful, it was outright misleading. One of the worst I remember was a project which unsurprisingly was named after a game of thrones character. As I never watched game of thrones it took me about two weeks before I could even remember the stupid name, during which time I was also dumbfounded as to how the program worked until I real…
I remember the era when sys admins would name machines or environments after nerdy shit like Tatooine, Dagobah. And you had to memorise which was the test environment and which was the mail server.
Thankfully I have never seen that in code.
Re: How Developers Choose Names
#147I just use a UUID for every variable name to make sure the codebase never has any ambiguity. No one is going to confuse e7693160-b5cf-4761-9202-de019cfd0fc9 with c3d8b9ac-d0da-4bbc-912b-025ce4e47f62
Re: How Developers Choose Names
#148I just use a UUID for every variable name to make sure the codebase never has any ambiguity. No one is going to confuse e7693160-b5cf-4761-9202-de019cfd0fc9 with c3d8b9ac-d0da-4bbc-912b-025ce4e47f62
This implies your code has fewer than 2¹²² variables. A real coder should have more than that in each method. Sounds like you're basically a glorified VB "dev."
How did you know?! Actually it's probably not far from the truth... most of the code I write is more like scripts in R & Python and small utilities than fully-fledged applications. And lots of SQL. I glue a bunch of stuff together, and after that is where my real job begins. I used to have a bit more fun writing C code to work around the limitations of an ancient ERP: that system's foundations literally extended back to before the moon landing and long before I was born.
Re: How Developers Choose Names
#149I just use a UUID for every variable name to make sure the codebase never has any ambiguity. No one is going to confuse e7693160-b5cf-4761-9202-de019cfd0fc9 with c3d8b9ac-d0da-4bbc-912b-025ce4e47f62
Re: How Developers Choose Names
#150Earlier quoted context omitted.
I have never understood the practice of using a verb phrase ("get") for functions with no side-effects. To me it makes more sense to name the function after the result, i.e. Instances , InstanceIds , AllInstanceIds etc.
Like other's have said, I might use "Get" to signify that this is a complex operation. Although I prefer more descriptive words like "Fetch" or "Find". So FetchInstances() is expensive (each time it's called) but the property Instances is cheaper or only expensive on the first access.