- 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
This comment is self commenting (and frist)...
No, it isn't spam either
Admin
public string TextToDisplayWhenThisCommentIsFrist() { return "Frist"; }
Admin
Actually, writing code like that (correctly though, since the method shouid be "TheFormIsValid") is a good thing. The Ruby community in particular is fond of creating little wrapper functions around calls simply to make them read better.
This developer had his priorities backwards, however.
Admin
Other than the rather long method and variable names in the 2nd example, this is not really WTF code. It's readable and understandable. The names in the 2nd example could have been written better to make them shorter, and still understandable i.e ActivityNotRegistered(Activity) instead of ThisActivityIsNotRegisteredForThisEvent, but that's not a huge issue. I'd rather put up with that than XMeth(Y) and somevar anyday.
Admin
static public bool TrueIfNotReallyAWTFBecauseCodeLikeThisIsOutstandingAndAnExcellenetDocumentationTechnique() { return true; }
Admin
IME everyone that has ever written "self documenting code" to that sort of ridiculous extent was deliberately taking the piss out of someone (usually the idiot managers who decided to impose ridiculous coding standard rules on the developers).
Admin
It isn't spelled right either.
Admin
You mean 'spelt'
Admin
Why not just
public const bool TrueBecauseItsTrueAndItsNotFalse;
I can understand good naming of methods and variables, but creating wrapper methods to create self-documentation is indefensible. Use good naming to begin with and you won't need wrapper classes.
Admin
I'd hardly call it readable. CamelCase becomes nearly totally unreadable after the 4th word, and underscores are better even before that.
Admin
TrueBecauseThisEventDoesNotRegistrictBasedUponActivityType
ThisEventDoesNotRestrictRegistrantsBasedUponActivityType
Nice to see RestrictRegistrant being shortened down.
Admin
If the developer had made one of his TrueBecauseIHateJustSaying"True"() functions return 1 instead, they could have had a real problem.
Admin
Self Commenting
Admin
Please don't feed the trolls.
Neither spelling of "spelled" or "spelt" is "incorrect". Yes, in the US, "spelt" is almost solely used for a type of wheat mainly grown in Europe but everyone with half a brain knows that the language used in the US only bears a passing resemblance to English.
In "real" English, either form is acceptable and commonly used.
Admin
That 50 character length function name is surely a sign of the times. I learned my craft back in the day when software engineering was a serious discipline, before the kids turned up with their IPad/Facebook/Web2.0 bullshit.
Back then 16kb was considered a LUXURY and we had to learn to write highly efficient and compact code so that it would PERFORM. Well I am sure you've all heard this before and I don't want to bang on about some "golden age" - it wasn't perfect I am not saying that. It's just that an engineer who wasted programme memory so frivolously creating a 50 character identifier back then would have been fired on the spot.
I suppose modern businesses tolerate the complete waste of resources today because computers have got more powerful and the customer rarely complains. But you have to wonder how much faster typical software would run if it was written as per the old ways. There's also a slippery slope in play - out there now are a load of upstart "programmers" who are making all the software we use but they have no idea about how computers work let alone basic compiler theory. And people wonder why there are so many security holes and viruses in software these days...
/rant
Admin
Indeed and the same is true of the word learned/learnt, something I just had to look up for my previous comment.
Admin
I find the last one beautiful.
Admin
I remember when methods were verbs.
Admin
Admin
minifiers and obfuscation /endrant
Admin
TGFI
Thank Goodness For Intellisense
Admin
IFailToSeeAProblemWithThis. SelfDocumentingCodeIsCompletelyUnderstandableByAnyoneUsingIt. ItAlsoEliminatesTheNeedForThosePeskyComments. EveryJavaEnterpriseShopShouldConsiderDoingThis.
Admin
Admin
Perfect technique for developers with an attention span that is less than 10 seconds.
Admin
So is this:
Admin
Not only does this code style hurt my eyes, but it does an effective job of hiding potential bugs. There may not be bugs in the example code fragment but it is so completely hidden by the overgrowth that it takes more than a second glance just trying figure out what is actually going on -- assuming the self documenting method name is correct.
Ten years down the line, out dated comments in the code can still be useful as a guide to what the developer was thinking rather than what was implemented. This is a tremendous help when trying to maintain the code when all other documentation is also out of date or missing.
In this new world of self documenting code, I happily remain an unconverted Luddite (for now).
Admin
So I've been reading this site for a couple of years now and I can't seem to place the 'frist' meme... Can anyone provide the link to the story that started that this terrible thing?
Much Appreciated
Admin
ThatWasMyInitialThoughtToo. ClearlyTheyAreBeingPassiveAggresiveWithHoweverImposedThisStyleInTheFirstPlace.
Admin
Except it's still a pain the ass when the only difference between two (or more) 50+ character variable names is in the last 5 characters!
Admin
If you're not taking the mickey in your second paragraph, how about using your VCS to see the code history and hence outdated comments rather than keeping them live?
Of course if you are taking the mickey, I'll just mumble to myself quietly :-)
Admin
And smelled/smelt, spilled/spilt, etc.
Americans just don't like that "lt" ending. But they are usually okay with dealt rather than dealed.
Admin
That's why we told the British that FORTRAN spelled the short PROGRAM. The French spelling wastes two bytes.
Admin
When you start learning programming they tell you "there are variables, which can hold a value, functions, which are like actions and classes, which are like a type of object". Lies!
Then you try to get an MD5 hash in Python and you have to do this:
Hey! Since MD5 is a function (string -> hash), why not make it, you know, a function! (yes you can do it in one line but that's not the point)
Sorry that was an offtopic rant. Also I hate setter and getter functions that only consist of "this.value = value" or "return this.value". Anyone who creates a language where they are necessary is a dickweed arsehole.
Admin
What is so wrong with comments? I see this kind of crap and wonder what anybody has against comments. I agree, self documenting is good, to a point. Naming variables accurately is good, but method names don't need to say everything that happens. That's what javadoc comments are for, and they're good to have anyway in case you want to, you know, actually produce javadocs.
Admin
Look into encapsulation and the "law" of demeter and you will know why these simple get/set methiods exist. It's not the language that requires them, you can make your variables public, but then the thing that owns them has no control over when and how they are updated.
With that said, when the methods are this simple, where the hell are your business rules on validating the values that go into them? Are they being processed elsewhere? If so, why not in the setters to prevent bad values from even entering the picture. I don't blame the language for this one, but the "programmer".
Admin
Most of the code I write today is passed through some sort of minify/compiler process. This allows us to use long method names, with a relatively small memory foot print.
Psuedo Code example: function DoesTheDailyWTFPublishNewsArticlesEveryDay() { return false; }
Becomes in production: function a() { return false; }
Admin
Controller talking directly to (or instantiating?) the view? Not the most ideal application of MVC either.
Admin
Indeed. One of my pet peeves is object-oriented frameworks that create objects for actions. Actions are methods, kids.
Ah, but if you just use a data member (variable) then you lose the benefit of calling other methods from your getter/setter to produce unpredictable side effects!
Admin
Admin
Comments on "finished" code, however, are potentially far more useful, especially if the consumer just wants the functionality and doesn't expect to dive into the code themselves.
Admin
Oh boy, sounds like you used to walk to school barefoot, uphill, both ways...
Have you heard of Moore's Law? The tremendous gains in processing power and storage mean that we can develop software more quickly and leverage higher-level design constructs without getting bogged down in the muntia of shift registers. 16kb is, in fact, no longer a luxury...
Admin
Agreed. Look at the "return true" and absorb. If you need to know in detail "why" then you read the comment. One of the nicest manuals I ever read was in the early days of "microcomputers" (pre-PC days) that was printed using 3 typefaces and indents. The first was big and bold and simple. The second had details. The 3rd was small and deeply indented and contained all the gruesome technical details that mostly you didn't need except in problem-solving situations.
Get the detail you want at the point you need it; it's a mindset you don't encounter often.
Admin
"Registrict."
Fixed that for you.Admin
Maybe they should use Doxygen instead.
Admin
This is definitely more acceptable alternative than production code where all variables are like int i; int j, string str; etc.
That kind of code become very confusing for developer, yet we see severe examples of such coding practice in project.
Was code review not held to consider the horrorofying effect it will have on future programmers who have to work from offshore development centers in US time-zones?
Admin
I'm guessing you've not been doing dev for long enough to learn from experience. Comments in theory are great. In real life they're often wrong or useless.
Comments are code, and if they are there should be treated to the same quality control process. Unfortunately they're invisible to much of that process - the computer ignores them so there's no compile or test failure, so you're left with stuff like peer review, and too many people simply don't understand the problem.
If you're one of the few % who maintains your comments as well as your code, I'll congratulate you. The rest get me grumbling at them.
Admin
Admin
I remember when Engineers had to have degrees and built tangible things.
Admin
Jesus fucking himself with a huge horse dildo! Why did it take so long to get properties right?
Admin
Who do you think you're kidding?