|
I think that this piece of code is adorable (in a coding horror kind of way). Reminds me of a scene in Tarantino's Kill Bill pt.1, the one where Uma Thurman was slaughtering bad guys in Japan )))
I've really enjoyed all these cases in the code, but it is the size of this method that makes me dizzy.
I still wonder how the PM or co-workers haven't done something before this method grow that big.
|
|
|
|
|
makumazan84, when PIEBALDconsult talked about blood, I thought that exact scene you described. Kill Bill is a masterpiece ... and the code, of a very particular way, it is also.
As you get dizzy, I think in Visual Studio that could be solved with several sections #region.
Marcelo Palladino
Brasil
|
|
|
|
|
hmmm...in VS2003 and in VS2008SP1, you can't define #regions within a function body
|
|
|
|
|
Dammit!
Marcelo Palladino
Brasil
Twitter: @ProgrammerHead
Blog (pt-BR): http://programmerhead.wordpress.com
|
|
|
|
|
Palladino wrote: Dammit!
Yeah, I had the same reaction the first time I wanted to use it, some time about two years ago. I dislike large function bodies, but realistically there are a number of situation-specific algorithms that depend on a long sequence of unrepeated operations. To reduce the size, one is left with the option of breaking them into smaller chunks as subroutines, then calling each subroutine in sequence. I've seen differences in how well that approach works when maintenance is being performed by novices to the software. I've seen genuinely intense frustration expressed by some developers when they have to nest down through two or more levels of subroutine that were simply put in to eliminate very lengthy code sequences, where the developer in question felt it would have been much easier to follow the sequence in its original lengthy form. Allowing collapsible regions within a subroutine brings the best of both techniques to bear on the problem.
|
|
|
|
|
Hi,
I'm merely passing this on following a conversation I had with my dad the other night but thought it deserved a mention. I've no reason to doubt him on this one. I think.
A bit of background - my dad started work in computers back in the '70s (and did indeed use punch cards and such like). Eventually, they had a simple editor, higher-level languages were being used and programs were getting more complex and at some point, contractors from the States were over writing some applications for them.
He claims he still shudders at the memory of looking at their code after they'd gone and discovering that they'd left a small chunk of their homeland behind - the majority of variable and function names were named after baseball players...
Kev
|
|
|
|
|
I have worked in places where the naming "standard" is to use whatever name pops into the programmer's head at the time; preferably a short name so that it would be faster to type.
Sadly, there are still many programmers who are vehemently opposed to any kind of naming standard, they seem to think that such a thing is unnecessary and saps their creativity. They often use such creative variable names as a, b, c, etc. At least baseball player names can be searched for in the code; it just isn’t practical to search for a variable name of “a”.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
For a Pascal class many years ago I used nonsense words and the type was indicated by the number of syllables.
|
|
|
|
|
Ouch. And did you pass your class?
|
|
|
|
|
I want say where but at a past place of programmig (coudl be school or work) we came up with the below as a joke to see who could cathc on. It was for osmething that was not production so we didn;t have to worry about actually hurting any user, just havings ome fun...
The below I just pseudo code to demonstrate the variable names and functions we came up with:
DIM iWTFIT01
DIM sWTFIT02
DECLARE FUNCTION iWTFDID(sWTFAMI02 AS STRING) AS BOOLEAN
Can you guess the pattern?
|
|
|
|
|
|
Then this has long since become a tradition and cannot be a horror
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
Well,
try to debug a piece of code where all the variables are named Pippo01, Pippo02, Pippo03...
I guess you will change your idea
Bye By(t)e
|
|
|
|
|
Actually, that would not hold me up very long. But you are right, it's not good style as the restrictions to naming variables have become history.
Long ago, when the Atari 800 still used to be a good machine, I 'unprotected' a game which turned out to be written in BASIC. They used a simple encryption to disguise it and also 'obfuscated' the BASIC code by renaming all variables to something like X1, X2 ... X3456. I even still remember which game it was
Before that I used to write machine language programs on my first little computer where even an assembler was a luxury. At this level your program is just a heap of hexadecimal values, but I'm still used to it. Recently I restored one of my earliest programs from the old cassette tapes and posted it to be used with emulators or the few surviving real machines.
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
I'm not sure what's worse - baseball player names or Hungarian Nutation. Now where did I put that decoder ring?
|
|
|
|
|
Hmm, hungarian notation is probably as popular as RPN. I should start my old FORTH and code something, using hungarian notation.
http://en.wikipedia.org/wiki/Reverse_Polish_notation[^]
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
tom1443 wrote: Hungarian Nutation
Nutation is indeed a fitting term for that. Did you intentionally misspell this or was it just a Freudian error?
|
|
|
|
|
Totally intentional, I was wondering how many people would pick up on it.
|
|
|
|
|
Awww, you're making me question my worth as a human being... I appear to be the only person alive who thinks hungarian notation is great. I find it much more useful than that infernal camelCase.
(Sunglasses because I cannot be seen in public after this).
|
|
|
|
|
I fondly remember a time at university when I coded some neural network stuff together with two friends. We frequently came up with all kind of silly variable names taken from Asterix comics, out of the midst of some of the more witty parts of our conversations, and the like.
On one occasion we were looking at a boolean variable that we realized we forgot to initialize, causing an error. We discussed whether we should initialize it to true or false, so I sat down and wrote:
bool isgood = true || false;
|
|
|
|
|
At one place I worked, there was this idiot who named all his subroutines after Disney characters
BALR 8, GOOFY
Another place had code from consultants that was complete alphabet soup with no comments.
function doIT (a, b, c, d, e)
But one guy I worked with insisted all routines and variables had to be 8 characters long. His method was to come up with a description like "Print Spooler" and then divide 8 by the number of words and then use those characters to make the label "PRINT SPOOLER" becomes "PRINSPOO". All well and good until you come up with a name like "SHIPPING STATION CONTROL LOOP" which became "SHSTCOLO" (pronounced "sheh steh coe low").
Psychosis at 10
Film at 11
|
|
|
|
|
BrainiacV wrote:
"Another place had code from consultants that was complete alphabet soup with no comments."
function doIT (a, b, c, d, e)
Hey, I think they stole that method from the place where I used to work!
Also the desire to limit names to 8 characters should have died when programing languages started supporting longer names.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
I could handle the 8 character limitation better than I could the output from another coder working in a language that supported 32 character names. He liked creating long names that ran up to the limit. That wasn't the bad part (aside from making statements cover multiple lines to get anything done), the bad part was that he couldn't spell! So now you had to type all these long names with his mis-spellings. Sometimes his names didn't make sense "FireHunterSeekerBlowBackTo"
Psychosis at 10
Film at 11
|
|
|
|
|
I don't mind longish names if they are actually descriptive and useful. I really don't like names (short or long) that serve to obfuscate the code.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Today my esteemed coworker invented a brand new programming paradigm: Redundant Coding (tm).
This buggy old legacy code we are working with has a least three almost identical and insanely complicated instances of a special form of coordinate transformation. We want to simplify, but which one to keep?
My coworker suggested that we compare the results of the three code blocks too see which one, if any, would give diviant results. This immideately lead to the idea of letting the three instances "vote" on the right result. And BAM the Redundant Coding programming paradigm was born.
Just as a jumbo jet has three of everything just in case, our code has three almost identical code blocks, just in case one of them is buggy! If one code block produces deviant results, the other two will take over!
I am, of course, kidding. We will clean this mess up eventually.
|
|
|
|