|
"The beginning of wisdom is the revisit (accuracy) of naming"
Antisthene, Athens 445 b.C.
|
|
|
|
|
It's after years and years that you really understand, they're all the same and nobody cares what you use. :facepalm:
On the important note: I just put whatever makes sense. In an object itself, "Id" (or ID, or id—for some languages as their casing goes) is enough. But when building a relationship, I put the name of the reference table.
As for the variables (in the type, loop, etc.) I do try to make as much sense as I could, but iDontTryToElongateTheVariableNameJustForSomeReadability.
Besides, why make that many variables? Offload the stuff, using polymorphism, inheritance, composition, etc. They are there for a reason, right?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
This is one of the reasons I like case insensitive languages. id, ID, iD, and Id are all the same.
|
|
|
|
|
Naming is hard, some of my cow-orkers create wonderful names.
There's the "English" issue, as all of us are German native speakers, and some of us "know English", i.e. that English is a foreign language: enjoy names like "DataEdit" instead of "EditData" because Kevin does not understand the Subject-Predicate-Object rule (or does not understand that "Daten" is object (instead of subject) in the German phrase "Daten bearbeiten".
And there are people who cannot express their thoughts in their native language either. What does "m_ActionQueueFinishedWaiterCanceler.Set();" do? Also "bool m_RunWaitForExtinguishCannonRepairingDone;" looks funny.
And you may find some misleading items. E.g. a "Property" whose getter is actually a state-toggling function with many more side-effects...
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
FillKunde() - my long time favorite. While I certainly would like to push some of them into the oven, I never got a good recipe for a filled customer. That method also did not help. Just some chaotic juggling with DataSets, if I remember right.
That kind of throwing different languages into the pot and making a stew out of it always made my teeth hurt, but at least I now have heard a reasonable explanation for doing that. The customers tend to use certain terms for certain things. Translations can be confusing at times and if you don't want to read the code without the help of a dictionary, it's less misleading to merrily mix languages. Besides that, keeping your dictionary of translations up to date is also a challenge over the years.
Don't ask me what to do when a customer comes along who speaks a very different language or uses a different alphabet. Russian or Chinese, anybody?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
At least Germans don't have to debate Camel case and underscores. A long alphabetic string will do nicely, as long as it's capitalized if called for.
|
|
|
|
|
Pascal case and underscores are fine. Camel case is an abomination before God.
Software Zen: delete this;
|
|
|
|
|
I actually use PascalCase for most things, even function names and most constants, but use camelCase_ for member data.
|
|
|
|
|
Strangely it alwas were those projects that had devolved into an undocumented chaotic mess that were zealously watched over by the code lawyers. They had rules and conventions thicker than some countries' lawbooks and could spend hours debating how this or that should be written. Not a single second wasted on cleaning up the mess. Lipstick on a pig. But the bosses were pleased by our enormous progress, measured by how many inches the rulebook with all rules, exceptions got thicker.
But what do I know. Eventually everybody left the company, and that was not the first time that this had happened. As far as I know, this (more than 20 year old) monstrosity has been put out of its misery by the customer by now. Anyway, whenever I move on to a new job now, I'm on the lookout for red flags like this.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
After all, I have a 4k screen... But it hurts when you have to bugfix on laptop with just 1600x900 screen
|
|
|
|
|
I remember working with a Physics code, where the original programmer had used the least number of variables for the program to run.
During the first part of a program, he had defined a variable called velocity , which represented velocity itself. However, in the next part of the same program, he had divided this velocity value by a time-increment, thus making it represent acceleration, even though the variable was still called as velocity . Though the original intent seems to be having minimal number of variable definitions, it became a maintenance nightmare because the variable name and physics entity were different in different parts of the same program listing.
|
|
|
|
|
When I was going to a local community college in the early 80’s I had a part time job in the computer lab typing in the code of other students. The lab had a PDP-11/34a and more students than terminals so they get the students to write their code on forms (BASIC, COBOL, RPG II) and I would save them the time of sitting there typing their code then they could come back later and make their changes, fixes, whatever. I was fairly quick and accurate which made it somewhat practical. Anyhow, one guy had submitted a COBOL program and he used some pretty strange names. He had a line counter variable named BEERS-DRUNK so there was a line of code which read:
IF BEERS-DRUNK > 50 PERFORM GET-SICK
GET-SICK was responsible for sending a page break. I talked to him about it and he said he wrote the thing based on going to an oyster bar. I wonder what happened to him.
|
|
|
|
|
when testing some javascript thing in browser console, all variables are d of dd
when writing production code, might rename 1 or 2 times.
when writing hobby code, monthly fall system renaming schemes to make all nice
|
|
|
|
|
But you must not use "xxxEnum" ...
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I've seen MS using 'FunctionameExExExExEx' - is that acceptable?
|
|
|
|
|
If MS says so, it must be! (For now.) It's OK to use _ for private fields (again) too; but only one.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I have a product which I'm now responsible for that was written by an asshat who followed the option in the subject line. He deliberately wrote the code such that he was the only person who could maintain it. It's written in early 1970's vintage C, even though the product was started in 1990. Everything is global. There are types and variable names that are single, lower-case characters. Most identifiers are 6 characters or less. Source file names do not denote their contents. Header files do not declare the functions in the corresponding source files, if they even exist. Function prototyping isn't used - at all. The wacky guy even redefines #define 'd constants in windows.h because "Microsoft did it wrong".
This product was not under active development, so management assigned the guy to another product. For six months he refused to do any work. At the end of that time he was 'spoken to', and responded by retiring with no prior notice.
I've made exactly one change to this product, to replace support for some obsolescent hardware. It took over 100 hours of preparatory analysis to locate and verify all of the potential side effects, and a little over 4 hours to code, debug, and test the replacement.
I've been a professional programmer for a little over 42 years. In all that time I've worked with people I didn't like, but I've only hated one: this guy.
Software Zen: delete this;
|
|
|
|
|
Wouldn't it be faster to just re-write the thing from scratch?
|
|
|
|
|
I could probably rewrite it in 12-18 months, if I could spend full time on it. Unfortunately the demand for this product line is waning, and wouldn't warrant the effort.
Software Zen: delete this;
|
|
|
|
|
You could consider it fortunate that the demand for that product line is waning as then it won't matter.
|
|
|
|
|
That story reminds me of when I went to work for a manufacturing company in Dallas many years back. One of my first tasks was to update/complete an existing ASC X12 application that my predecessor has created, that was not quite functional yet. Basically handling purchase orders (850 Documents) and putting that data into a Btrieve database for Micro-MRP Max Manufacturing and Requirements Planning software that the company ran on.
There were no defined structures anywhere, everything was a void pointer with memcpy operations to the void pointer address plus an offset. I told my boss, I can either update his code, which would take a couple of months at a minimum, or write a fully functional replacement from scratch in a couple of weeks that was much easier to maintain. I ended up writing a replacement from scratch. That initial work became the inspiration for for a full blown ASC X12 class library I wrote in my spare time and licensed to the company free of charge. Developed a parser that interpreted the ASC X12 documentation and generated classes for each complex data type and document type.
Eventually, I ended up licensing out that class library to a few other companies as a side hustle.
|
|
|
|
|
Have seen a Stanford University video in which he shows a coding horror:
#define SEVENTY_TWO 73
|
|
|
|
|
... I really hate it... No knowledge about the business, but only correct namings
|
|
|
|
|
Consider yourself lucky.
Sometimes, computer people break into professional fields they do not know, forcing onto it their own misunderstanding of the terminology, twisting it around badly. But they are such holy, untouchable gurus that noone dares lift their voice against, and tell that 'But that is not what is meant by that term!' Rather, the misunderstood use is taken up as the new, modified meaning.
E.g. pick up a textbook on typography, 30-40 years old (or more): It uses the wrong terminology! Oh well, at that time it was The established terminology, but then came this holy guru saying things differently, and we had to adjust to him. He is holy and untouchable, and he has made his own font and typesetting system. We must follow what he says, or we are doomed.
|
|
|
|
|
...that's all that needed to be said about being "careful" with naming (and writing in general)
|
|
|
|
|