- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"An array consumes too much memory! That would be terribly inefficient." "This implementation provides much more extensibility!"
I can see the 'Senior Developer' was practicing Leveraged Synergies.
Admin
I won't have to support this once I'm done making it!
Admin
That's 701 columns.
Admin
public static readonly int ColsMaxCapacity = 700;
Yet the columns start at Col0 and finish at Col700. That's the real WTF... well that and the whole bloody thing.
Admin
What isn't shown is the wrapper method:
Yeah, and I don't care if there is no eval and I don't know how to do string concatenation. It's a joke. So there.
Admin
Ah, but 701 columns makes it flexible so that it can handle sets that start with column 0 or column 1! Brillant!
Admin
Admin
Thats just terribad but unfortunately not unlikely...
Admin
Why stop here? Support for variable column amounts is easily implemented!
-HistoryResultRowWith001Cols.cs -HistoryResultRowWith002Cols.cs
...and so on, ad nauseum...
-HistoryResultRowWith699Cols.cs -HistoryResultRowWith700Cols.cs
Admin
I think my brain just puked
Admin
This is done for security.
Admin
Now, it's this kind of coding that makes me think that death penalty (to which I'm firmly opposed) is not such a bad idea, after all.
Admin
Hey, now. We're being overly critical. Arrays are not the only way to go.
He could've used a java List<E>. Then, there wouldn't be that pesky 701-element limitation - them Add() and Remove() functions are beasts, y'know!
Admin
Admin
Hey, that guy is missing the private variables for storing the value internally. And the Property Changed events! He has to re-write all those things, like:
Admin
Your line count is down for the day, you have been demoted to coffee boy
Admin
Even if you have somehow never heard of data structures that could handle this sort of thing for you, if your brain can produce this kind of code without screaming, "THERE HAS TO BE A BETTER WAY!" (and then searching for said better way), you should not be allowed near source code.
Besides, TRWTF is tables with 700 columns.
Admin
Apparently the "senior developer" had a "senior moment" when he wrote that.
Admin
The data set has up to 700 columns because the senior developer also developed the database. He decided to just use one big flat table to cut down on joins. This was presumably done for "performance" reasons.
Admin
Having seen this mentality many times in the past (I was fired two months ago from a job I had for nearly two years for trying to get the team to realize "there has to be a better way"), let me explain why it usually happens. The "senior developer" was probably given a task that needed to be done fast, with little or no requirements. Said "senior", not wanting to ever say "No" or "I need more time" or "I need requirements" to his boss, did this in the first thing that came to mind: properties for everything. He never once thought of a better way, because he finished the task as fast as humanly possible and forgot all about it. When he had to add things, he couldn't ask for the day or so to go back and change it to an array, so he did the next logical thing: Simply add to it, that way he could just copy and paste what he had done previously and finish the task in a matter of seconds instead of "wasting" a day or more refactoring.
That's the mentality of these kind of people. They don't think, because all they focus on is hacking up a solution as fast as possible because they dare not appear to be wasting time to the boss, and they continue to have that mentality by just copying and pasting their poor solutions all over the place.
And yes, I've dealt with something similar to this, although we didn't even use a class we just accessed the DataSet raw, since there were so many columns. At least that's not as WTFy as this nonsense.
Admin
Data normalization is for PFYs. Even they should have better things to do. Like fetching the senior developer's coffee and combing the bits of donut out of his beard so he can concentrate on adding support for an additional 324 columns (forwards compatible with expanding business requirements and powers of 2 are more efficient).
Admin
This will be much easier to later maintain if we ever need to add pre-processing rules to a column of data.
Admin
TRWTF is #region. Who needs types or semantics when you can express everything in terms of IDE code folding?
Admin
The comments speaking about regions reek of someone being socialized in the mainframe world. This would not explain the absence of arrays, though - even COBOL allowed them. ;-)
Admin
"My God! It's full of HistoryResultValues..."
Admin
Admin
Dang...that should have been a "Diego" quote. :(
Admin
But that's way to inefficient. You can achieve the same with a simple if/elseif construct:
Admin
You see, that's why you will never get promoted to senior developer or management roles... All you have managed by doing this is to increase the bugs per line metric.
Me also thinks the senior developer was once a contractor paid by lines of code... Offcourse, the company could not let him go after this, and hired and promoted him ... Story of life ...
Admin
Maybe it was just a matter of poor word choice!
Developer: "Boss, have you seen this table? I want arrays!"
Boss: "No way you're getting a raise; just deal with it!"
=0)
Admin
No, I'm pretty sure that the SLOC metrics in place there would indicate that an 80% reduction in SLOC indicates that the project is now 80% farther from completion! Any reduction indicates low productivity, don't you know.
Admin
This was obviously written in the brief span of time that C# didn't support arrays, but did support automatic properties.
Admin
I wonder if this developer got promoted to senior position because the company's performance metrics system hilighted he was one of their most productive (based on lines of code per day)
Admin
private string GetRepeatedSourceCode(int numOfRetardation) { string result = ""; for (int i = 0; i <= numOfRetardation; i++) { result += "public HistoryResultValue Col" + i.ToString() +" { get; set; }";
Admin
Not sure what language this is, but in Java he could just use reflection to access the columns. Build another class that accepts something like obj.getHistoryResult(34) and it would use reflection to call the correct method.
Or, of course, he could just do something lame like implement it as an array...
Admin
The sad thing is that I've seen people implement this pattern because they think it'll save time over arrays. Yeah, no. Although it might save a single arithmetic instruction on a compiler that's terrible at optimizing, the cache performance, along with the getter/setter function overhead, will result in an overall drop in performance, guaranteed.
Nowadays, with optimizing compilers and well-designed standard libraries, it's incredibly unlikely that small optimizations to your existing algorithm are going to make a difference.
While I'm here, one of my favorite compiler optimizations ever: GCC can detect soft infinite loops (e.g. while (some_int <= MAX_INT)) and replace the conditional branch at the end of the loop with an unconditional jump.
Admin
The very first time, even if the number of columns was small (e.g. 10), he should have used collections. For not using columns, he's a senior dumbass. The 2nd time he was adding properties to this class, since he hadn't taken time to change it to collection, he's a senior dumbass. If the number of columns that first time was larger, he's still a dumbass for not using collections. And you're a dumbass for defending him, even though you maybe had not (since, however, you sound like you had).
Admin
"For not using columns" = "For not using collections"
Admin
I like this kind of coding. You can write it in Excel.
and that gives you scope for many more columns
Admin
I like this kind of coding. You can write it in Excel.
and that gives you scope for many more columns.Admin
An excellent table...
*captcha: ludus Let's play with arrays ?
Admin
Is it just me, or is anyone else dying to see how HistoryResultValue is defined?
Admin
As an enum that stores every possible 64-bit int.
Of course that's impossible, so they just kinda had to add values to it as they went. As a result, INT_300000 has the actual value 3255.
Addendum (2012-09-27 12:52): And for the record, when I say "impossible," I mean that if you were able to find a place to buy 128 GB microSD cards en masse, you would over 17 billion of them to store such a file, and that's with some pretty conservative estimates for how large such an enum declaration would be.
Incidentally, that many micro SD cards would occupy a cube 11.23 meters to each side and would weigh 4.3 kilotons.
Admin
That's TRWTF right there. If the compiler can detect something like that, the appropriate response is not to optimize it, but to issue a warning, because the code is most likely wrong.
Admin
It does under -Wall, I think the warning is "condition is always true due to data type limits" or something like that.
This is why you always use -Wall when using GCC.
Admin
I am not a senior developer. I am self taught script kiddy. Even I know better than to do this. If this is what senior developers do I am glad I am not one.
Admin
Admin
Did I sound like I was defending it? No. I've seen a lot of "senior dumbasses" as you say write code like that, and what I said was the reason why. I've ALWAYS spoken against hacks like that, but as I said I was FIRED from the job because I kept wanting us to NOT write hack code. Rather than do that, they let the problem (i.e. me, the one good developer) go and kept the "senior dumbass" who hacked code via copy and paste because he was too lazy to do it right since that would mean telling the boss "No".
Admin
Agreeing re: TRWTF, I wonder whether normalization would lead to 350 tables or 699 tables. It depends, I guess.
Admin
It is very demoralizing when you constantly have to justify and explain why a quick hack is a bad approach to people who pretend to understand programming. More so when one of those people is the "Senior Dumbass".