|
Richard Deeming wrote: shame it's so limited. If only there were a way to make changes to it.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
If I had a few weeks to study Jamie's code, I might be able to work out how to do that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
switch (str)
{
case "4":
if (str != "5") ...
Ah, the joys of outsourcing with no code reviews.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
The naming of str bugs me just as much. Ok, I know it's a string. But what is it? Calling it something like invoiceTypeCode indicates it is a string and lets me know what I am looking at.
|
|
|
|
|
gardnerp wrote: The naming of str bugs me just as much.
It had a real name. I sanitized it.
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
I was guessing that the programmer had a Fortran background. Fortran has no reserved words (at least it didn't up to F77 - I haven't used more recent versions) so you could define INTEGER to be a REAL variable and COMPLEX to be an INTEGER variable, The result of multiplying INTEGER and COMPLEX could be REAL value stored in the REAL variable REAL. Spaces had no significance, so REALREAL and COMPLEXFUNCTION were perfectly valid variable declarations. (I am really happy that I never had to write a Fortran parser!)
When learning Fortran coding at the university, we made up lots of programming exercises for our own fun. One of them was to print out Pascal's triangle using predefined words only, and no literals. Our compiler allowed recursion, which was an extension to Fortran IV, but without it, I doubt that we would have succeeded. The code was completely unreadable. Maybe I should dig it up from the basement and post it here!
|
|
|
|
|
I recently inherited a load of "code" (it's VBA so I don't want to it ideas above its station ) ... during the "handover" (apparently that's what it was) the original "programmer" explained with great pride, that they didn't Quote: waste their time using long variable names... Yep! Every single one of them was a single character. Every. Single. One.
(Except where he copied code snippets off the internet)
|
|
|
|
|
CHill60 wrote: waste their time using long variable names It's likely they spent more time trying to remember and figure out what each single character variable actually was.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
The only thing we know for surte is that it isn't 5.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
You should have a mutex to make sure str does not change at that moment!
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
Good grief. I keep telling my techie wife that soon you'll see critical systems failing left and right that used to work pretty well. Shoot, maybe that's why AI is all the rage today. Were scared of, let's just call em the up and comers.
|
|
|
|
|
Maybe they need to check that left!=right ?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Yeah, you never know when 4 might turn out to be 5!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
It could be a Trekkie trying to be cute.
"There are four lights!"
"Are you sure?"
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
It's 3 weeks I am a consultant and I'm seeing sh*t like this way too often. And I am expected to produce the same, since I have to be productive with a 2 weeks training over a medium sized project with no documentation nor coding standard (functions that take 12 arguments named ct, ly, ex, ey, tx, fx and so on...).
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
den2k88 wrote: since I have to be productive with a 2 weeks training over a medium sized project with no documentation nor coding standard
Ouch! I feel your pain!
Latest Article - A Concise Overview of Threads
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
|
Oh my. This is what happens when people can get titles like "senior" based on time and not on skill. I need a drink after reading that
|
|
|
|
|
Mind you the corollary to that is when people have very similar long variable names CompanyIsAgent, CompanyHasAgent, CompanyAgent, IsCompanyAgent, IsAgentCompany etc etc in that they are all nice long descriptive names, but you cannot begin to comprehend the usage or meaning of any of them without studying the program context, and it's easy to use the wrong one and for the code to still run! (this is a real world example!). Using variable names like a, aa, aaa, aaaa and x, xx, xxx, xxxx etc (also a real world example) is hardly any worse.
Naming things well is hard, so I would go for brevity where possible and using objects containing properties if at all practical simply so the context can be easily acquired when reading the code
|
|
|
|
|
Did the guy knew about IDEs with auto-complete?
I understand the point that even if it takes a fraction of a second longer to type a variable name, it will save you several minutes/hours in the future when you or someone else has to maintain that code. But even that fraction of a second disappears with auto-complete.
|
|
|
|
|
Most of these people think that "vim is better" than a proper IDE.
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|
|
|
Quote: Did the guy knew about IDEs with auto-complete?
He didn't like auto-complete telling him what to type.
Quote: it will save you several minutes/hours in the future
He believed that some ephemeral future savings did not outweigh a concrete savings right now!
And besides, "a real programmer can figure out the code". Extra time to figure things was not important, but the fraction of a second typing time mattered. I believe the saying "Penny wise and Pound foolish" applies.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
I used to work with a guy who typed (mostly) with one finger - if he needed a capital letter he hit caps lock then the letter then caps lock ...
This was pre-IDE with completion days. His variable and function names were really terse. When we noticed his coding style, the functions we implemented in our libraries started to "change" so cpos(...) became setVirtualCursorPosition(...) and fg(...) became setForegroundTextColour(...) and so on
|
|
|
|
|
Not disagreeing with the idea that a symbol's name should tell you a bit about it (if possible), but I have worked with someone who who's symbol and function names were pretty near essays.
It takes a bit of common sense - and making distinguishing them a non-painful eye exercise. Why not loop with i, j, etc., as counters? Why not use IPAddr instead of ipa (slurp!)?
Always just common sense to make readable and to avoid mistakes. It shouldn't be hard.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|