|
The cases are listed alphabetically. But they forgot two of them: case "M" and case "V".
Maybe that's the reason why their chemical facility burnt down...
|
|
|
|
|
I thought his subject line made it quite plain what he regarded as wrong here:
Don't Repeat Yourself - There's a lot of copy-and-paste style repetition all over that method.
Separation of Concerns - This one method seems to cover a lot of ground.
Inversion of Control - This looks like classical procedural code to me.
Keep It Simple Stupid - 'nuff said.
Generally, any method over 20-30 lines should often be regarded as suspect. This is a true horror.
|
|
|
|
|
You got my points, Rob.
And Yes, it's a real life horror!
Marcelo Palladino
Brasil
|
|
|
|
|
This sort of horror is quite normal, but seldom are we given an example that we DON'T have to read...and thank you, those who did so!
|
|
|
|
|
No need to post the whole bloody thing.
|
|
|
|
|
You're right, PIEBALDconsult. Excuse me for this, okay? (Sorry, guys!)
I wanted to give a dramatic effect and, as a big fan of Tarantino, exaggerate the amount of blood.
I have this code posted on a blog on wordpress. You think I should edit my post and replace the entire code for a link pointing to the post in wordpress?
Marcelo Palladino
Brasil
|
|
|
|
|
Testing CP forum post limit may be.
...byte till it megahertz...
|
|
|
|
|
Hey, bleedingfingers, had not thought of this ... but now that you said, I was testing. I was testing ...
Marcelo Palladino
Brasil
|
|
|
|
|
That looks like at least a few dozens of function points to me.
|
|
|
|
|
Hey don't you have source control? No need to dump your code here
|
|
|
|
|
Good idea! I hadn't thought of that... use CP as an offsite backup facility. Hmmm. I wonder if the hamsters will complain...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
hahaha, this is not my code, but you gave a good idea. Can I even do versioning of my sources here...
Marcelo Palladino
Brasil
|
|
|
|
|
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
|
|
|
|