- 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
TRWTF is not make the type of object a parameter. You could have used this for text boxes, option buttons...
Admin
Well, to be honest, any decent IDE (which includes Visual Studio) will display the parameter list and where you are. Still, 36 parameters is pretty... impressive.
Admin
It's this irrational hatred of property initialization. I'm against hate.
Admin
Technically, this article doesn't belong on this site because it did not cause a "What The Fsck?" reaction. Indeed, I'm actually quite impressed --- thirty-five mandatory parameters demonstrates an astonishing degree of determination that you rarely see in a developer these days. Kudos to the original coder!
Admin
CreateRectComment(Comment, "Comment", "Fifth!", New Point(290, 5), someForm, Color.Red, Color.White, Color.White, 710, 300, Color.White, "Frist?", String.Empty, New Font(MainFontName, 48, FontStyle.Bold), New Font(MainFontName, 16, FontStyle.Bold), New Font(MainFontName, 28, FontStyle.Bold), TextEffects.Floating, TextEffects.Floating, TextEffects.Floating, Lang.InstructionErrors.PushInRedButton, TextEffects.Floating, New Font(MainFontName, 34, FontStyle.Bold), Color.White, Color.White, TextEffects.None, "", Nothing, Color.White, TextEffects.None, "", New Font(MainFontName, 12, FontStyle.Regular), Color.White, TextEffects.None, "", New Font(MainFontName, 12, FontStyle.Regular))
Admin
I see someone saw a problem - the same code was repeated. Then, they wrote code. They didn't write code that solved the problem, and they didn't write code that didn't introduce a new problem, but they wrote code. Sounds like 95% of our industry.
Admin
Ouch, this brings back memories of a job that I left only about 9 months ago. (It was my first ever development job after a mid-life career change, so I was very grateful for it, and the working conditions were pretty good - but unfortunately the codebase was as I am about to describe.) This was a legacy PHP application which had had no code reviews or anything similar in the 15 years of its existence, that we developers were still expected to constantly add new stuff to (an awful lot of things had been added by copy-paste over the years, by the look of it) - as well as fixing some of the inevitable mountain of bugs. (Needless to say there were no tests, and one bug fix could cause several other bugs.) I could honestly submit about a dozen articles about that codebase, if I remembered any specifics. (Unfortunately they all merge into just a horrible haze of WTF.)
Anyway, one of the many annoyances of this codebase, aside from the major WTFs, was the use of functions with about 20 different parameters. I still remember the horror of having to count them out to make sure I was changing the correct one, as well as setting all the intermediate ones explicitly to their default values.
Of course, the real WTF there is PHP - for all the obvious reasons but especially, in this case, for not having keyword arguments.
Admin
Admin
What if I want to add multiple controls of different kinds? A method that takes arrays and iterates over them using switch-case!
Admin
I don't see the problem. Previously, the poor programmer had to write FOUR lines of code to create a label.
Now the programmer has been EMPOWERED and can create a label in a SINGLE line.
That's a 75% SLOC improvement.
To go back to the old way of doing things, the programmer would have to write FOUR TIMES as many lines of code.
This kind of OPTIMISATION and forward thinking allows management to reduce headcount by at least 50%, and increase programmer salary by at least 10%.
EVERYONE WINS!
Admin
Seems to me this code was extraced from some other methods where it was repeatedly used. I know I've extraced some repeated code, only to find that I needed a shitload of parameters, because the lables would differ oh so slightly... but I made it a habit to make most parameters optional.
Admin
If the SLOC number is not going up rapidly, cleary the project doesn't need permanent developer positions. Reduce headcount 100% and give it to the intern to maintain. Then bring in HPCs instead.
Admin
As someone who is responsible for a VB.net project named "Label Maker", that is 10+ years old. This hits a bit too close to home.
Admin
Not so much fluent programming (which would arguably have worked better), as effluent programming.
I'm sure I've used this joke before, but it applies to the max here.
Admin
The first time I ran across keyword arguments was during a university class on IBM System/370 assembler - the assembler had keyword arguments in its macro language...
Um.
I took that class in 1985.
The PHP guys had no excuse, or maybe even less than that.
Admin
Ooh Thomas, are you German, by any chance? I may have had to use that product in my last job... (escaped 1.5 years ago to the land of React/nodejs)
Admin
I was thinking they should create a LabelProperties object and pass that instead for readability.
But the only difference would be the constructor for that object would have 35 parameters...
Admin
I think this function isn't Enterprise-y enough. It could stand improvement by making database calls for each of the properties.
Admin
Yes! Instead of hard-coding the parameter arguments, you can pass value identifiers that are searched in the database. Then you can change UI elements without redeploying.
Admin
I get that it's cool to bash on PHP on this site, but there are probably more languages without keyword arguments than with.
Admin
I like it AM - cynical thinking. Best solution, put a line break in for each parameter. Sorted.
Admin
I don't know if VB.net supports this, but with C# you get the best of both worlds with named initialization.
You can just do var label = new Label { Size = new Size( 710, 300 ), Text = "Operation:" }; someForm.Controls.Add( label );
Where the 'foo = bar,' are properties or setters on the object. Everything you don't override gets defaults. Perfect. If you want to save Lines of Code (lol) you can skip the temporary label variable.
Admin
Yes, VB.Net has that, that's why this whole thing is a WTF. This dweeb came up with a solution that solves nothing. Meanwhile, Microsoft enhanced the language so that the problem doesn't even exist any more. Even better, it's highly likely that Microsoft fixed the problem about a decade before the programmer decided to tackle it.
VB also had named arguments since day one. So, if numbnuts had bothered to make most of the arguments optional, then this disaster would have usually reduced down to a slightly strange syntax for an initialization.
Admin
True, but it was more a comment about the lack of newness in the idea.
Admin
@Robin: Except for the mid-life career change, you could be my colleague who just found a new job... and me...
Admin
Database calls are so passe. gRPC calls are the new hotness.
Admin
I recall writing a few similar functions over the years to generate UI in environments that had just transitioned from teletypes to screens with addressable coordinates. IOW, in the mid 1970s. As this code amply demonstrates, once you get much past MakeLabel( intXCoord, intYCoord, strLabelText, bInverseVid) it turns into a very bad idea.
But boy did that MakeLabel function (and it's counterpart MakeInputArea()) beat hand-coding all the escape sequences to create block-mode forms on an HP2640 or clone thereof. Not to mention adding VT-100 support a couple years later.
As always with these kinds of WTFs we're missing a critical property: When did this function first get written and in what language on what platform? If this originally dates from GWBasic on MS-DOS with an MDA screen we have a very different kind of WTF than if this was first written in VB1 on Windows 3.0 for an EGA screen vs in VB.Net 6.0 on Win10 in 2019.
The fact this junk code is apparently running today is a WTF for sure. But what kind of WTF it is matters. At least to us old farts.
Admin
Now I want a label with a different GradientFactor. But this stupid incomplete interface does not let me do that! Quick, copy the whole function under another name and add a GradientFactor argument! :)