• Hmmmm (unregistered)

    This comment is self commenting (and frist)...

    No, it isn't spam either

  • (cs)

    public string TextToDisplayWhenThisCommentIsFrist() { return "Frist"; }

  • (cs)

    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.

  • !IsSelfCommenting() (unregistered)

    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.

  • Re: Self Documenting (unregistered)

    static public bool TrueIfNotReallyAWTFBecauseCodeLikeThisIsOutstandingAndAnExcellenetDocumentationTechnique() { return true; }

  • Hmmmm (unregistered)

    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).

  • Bleat (unregistered) in reply to Hmmmm

    It isn't spelled right either.

  • TheSi (unregistered) in reply to Bleat

    You mean 'spelt'

  • Danno (unregistered)

    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.

  • a (unregistered) in reply to !IsSelfCommenting()
    !IsSelfCommenting():
    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.

    I'd hardly call it readable. CamelCase becomes nearly totally unreadable after the 4th word, and underscores are better even before that.

  • Lockwood (unregistered)

    TrueBecauseThisEventDoesNotRegistrictBasedUponActivityType

    ThisEventDoesNotRestrictRegistrantsBasedUponActivityType

    Nice to see RestrictRegistrant being shortened down.

  • mjfgates (unregistered)

    If the developer had made one of his TrueBecauseIHateJustSaying"True"() functions return 1 instead, they could have had a real problem.

  • Alex Papadumbass (unregistered)

    Self Commenting

  • Hmmmm (unregistered) in reply to TheSi
    TheSi:
    You mean 'spelt'

    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.

  • Geoffrey T. Buchanan (unregistered)

    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

  • Geoffrey T. Buchanan (unregistered) in reply to Hmmmm
    Hmmmm:
    TheSi:
    You mean 'spelt'

    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.

    Indeed and the same is true of the word learned/learnt, something I just had to look up for my previous comment.

  • Vlad Patryshev (unregistered)

    I find the last one beautiful.

  • Botia (unregistered)

    I remember when methods were verbs.

  • Your Name (unregistered) in reply to Botia
    Botia:
    I remember when methods were verbs.
    I remember when programmers were engineers.
  • hey (unregistered) in reply to Geoffrey T. Buchanan

    minifiers and obfuscation /endrant

  • Mikerad (unregistered)

    TGFI

    Thank Goodness For Intellisense

  • iToad (unregistered)

    IFailToSeeAProblemWithThis. SelfDocumentingCodeIsCompletelyUnderstandableByAnyoneUsingIt. ItAlsoEliminatesTheNeedForThosePeskyComments. EveryJavaEnterpriseShopShouldConsiderDoingThis.

  • Hmmmm (unregistered) in reply to Mikerad
    Mikerad:
    TGFIAWD

    Thank Goodness For Intellisense And Widescreen Displays

    FTFY

  • Darkstar (unregistered)

    Perfect technique for developers with an attention span that is less than 10 seconds.

  • Nickster (unregistered) in reply to !IsSelfCommenting()
    "this is not really WTF code. It's readable and understandable"

    So is this:

    return true; // because this event does not restrict registrant based upon activity type
  • PhilT (unregistered)

    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).

  • Clueless Guy (unregistered)

    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

  • Anon (unregistered) in reply to Hmmmm
    Hmmmm:
    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).

    ThatWasMyInitialThoughtToo. ClearlyTheyAreBeingPassiveAggresiveWithHoweverImposedThisStyleInTheFirstPlace.

  • Anon (unregistered) in reply to Mikerad
    Mikerad:
    TGFI

    Thank Goodness For Intellisense

    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!

  • clive (unregistered) in reply to PhilT

    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 :-)

  • Anon (unregistered) in reply to Geoffrey T. Buchanan
    Geoffrey T. Buchanan:
    Hmmmm:
    TheSi:
    You mean 'spelt'

    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.

    Indeed and the same is true of the word learned/learnt, something I just had to look up for my previous comment.

    And smelled/smelt, spilled/spilt, etc.

    Americans just don't like that "lt" ending. But they are usually okay with dealt rather than dealed.

  • Tasty (unregistered) in reply to Geoffrey T. Buchanan
    Geoffrey T. Buchanan:
    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

    That's why we told the British that FORTRAN spelled the short PROGRAM. The French spelling wastes two bytes.

  • CAPTCHA:sino (unregistered) in reply to Botia
    Botia:
    I remember when methods were verbs.
    This.

    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:

    m = hashlib.md5()
    m.update("mahstring")
    hash = m.hexdigest();
    

    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.

  • amis (unregistered)

    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.

  • (cs) in reply to CAPTCHA:sino
    CAPTCHA:sino:
    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.

    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".

  • mrfr0g (unregistered) in reply to Geoffrey T. Buchanan

    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; }

  • adiener (unregistered)

    Controller talking directly to (or instantiating?) the view? Not the most ideal application of MVC either.

  • Nickster (unregistered) in reply to CAPTCHA:sino
    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!

    Indeed. One of my pet peeves is object-oriented frameworks that create objects for actions. Actions are methods, kids.

    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.

    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!

  • Rob C. (unregistered) in reply to Geoffrey T. Buchanan
    Geoffrey T. Buchanan:
    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'm sorry, but if debug symbols aren't on, do any compiled languages even keep track of the function names? My understanding was the cryptically illegible nature of function names in older code was primarily due to compiler limitations, not performance reasons.
  • Rob C. (unregistered) in reply to amis
    amis:
    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.
    Depends on the consumer of the code. For someone who is likely to be modifying the code itself, comments as documentation tend to become stale and eventually misleading. Lazy coders will modify the code without touching the comments, and the next thing you know the comment is talking about something dozens of lines away, and is inaccurate due to implementation changes.

    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.

  • tundog (unregistered) in reply to Geoffrey T. Buchanan
    I suppose modern businesses tolerate the complete waste of resources today because computers have got more powerful and the customer rarely complains.

    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...

  • Aargle Zymurgy (unregistered) in reply to Nickster
    Nickster:
    "this is not really WTF code. It's readable and understandable"

    So is this:

    return true; // because this event does not restrict registrant based upon activity type

    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.

  • (cs) in reply to Re: Self Documenting

    "Registrict."

    Re: Self Documenting:
    static public bool TrueIfNotReallyAWTFBecauseCodeLikeThisIsOutstandingAndAnExcellenetDocumentationTechnique() { return FILE_NOT_FOUND; }
    Fixed that for you.
  • tabana (unregistered)

    Maybe they should use Doxygen instead.

  • (cs)

    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?

  • clive (unregistered) in reply to amis
    amis:
    What is so wrong with comments? I see this kind of crap and wonder what anybody has against comments.

    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.

  • Rajendra Kumar (unregistered) in reply to amis
    amis:
    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.
    Dearest Amis, Can you plz provide me with the codes for producing javadoc from C#? It's requirement from my hungry client. It's URGENT!!! Thx, Raj Kumar Executive Team Lead
  • me (unregistered) in reply to Your Name

    I remember when Engineers had to have degrees and built tangible things.

  • It's a Cock! It's a Fist! It's Zoonerman! (unregistered) in reply to KattMan
    KattMan:
    CAPTCHA:sino:
    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.
    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".

    Fields in Fantom

    Jesus fucking himself with a huge horse dildo! Why did it take so long to get properties right?

  • F (unregistered) in reply to Geoffrey T. Buchanan
    Geoffrey T. Buchanan:

    ... I don't want to bang on about some "golden age" ...

    /rant

    Who do you think you're kidding?

Leave a comment on “Self Documenting”

Log In or post as a guest

Replying to comment #:

« Return to Article