LMAO. A coding horror
http://blogs.slcdug.org/jjacobson/
Most of the times that they showed me what they considered a WTF in the pre-existing code, it turned out to be something that only advanced or experienced programmers would know, but which obviously confused them. It became such a habit for them to blame the pre-existing code that **the management eventually concluded, when the rewrite proved worse than fruitless, that the whole code base should be thrown out and a replacement started immediately in the most popular Microsoft language.**
LOL. You know it's true.
The firm we outsourced some development to coded up a gem:
if (someVar != null)
if (someVar != null)
someVar.DoSomething();
Just to be double double sure sure that the variable isn't null prior to it's use.
xampl
July 8th, 2007 6:46am
I've seen that before. What's happening is someVar is being accessed in two threads and the other thread sets it to NULL sometimes. Having two checks reduces the chance that you'll miss it changing after the first check. Of course, it still might change after the second check, but this at least plugs the point where they observed the error during debugging.
Practical Economist
July 8th, 2007 2:31pm
That was the other thing -- they were doing multithreading, and the code was peppered with statements like:
Thread.Sleep(436);
Thread.Sleep(28);
It seems that they were picking values that worked on their machines (most of the time, anyway). No synchronization objects were in use....
xampl
July 8th, 2007 3:23pm
Yup. Seen this enough I'd call it an anti-pattern.
Related to the JoS discussion going on now about how a CS degree is not necessary, all that is necessary is delivering business value.
Practical Economist
July 8th, 2007 5:43pm
It's partly not being able to work at a high enough level of abstraction, and partly being focused down in the weeds.
And partly a lack of education, you're right.
xampl
July 8th, 2007 7:22pm
Education is no substitute for intelligence.
bon vivant
July 8th, 2007 8:03pm
Yes I agree. Education isn't a panacea here, most CS grads don't understand concurrency any more than they understand pointers. But some do. In the non-degreed world, it's less likely that they've even heard of deadlocks or semaphores. I knew about it before I ever got a degree, but that was only because I was writing drivers for custom hardware devices I had built as a hobbiest and had to discover it all the hard way. When I took CS courses, then it was "Oh, so the proper term for all the incredibly subtle shit I've been doing is 'concurrency issues', gotcha".
Practical Economist
July 8th, 2007 8:26pm
^^++
I know deadlock. I also know better than to do .sleep or double-checks to avoid concurrency issues in threaded stuff, but I don't write much threaded stuff. I just know it from reading. But... I don't know semaphores.
JoC
July 9th, 2007 10:20am