• Prime Mover (unregistered)
    protected function getFrist($frist) {
        return $frist;
    }
    
  • Prime Mover (unregistered)

    And on Rupert's frist day at the office in his new company, he's invited into the special high-intensity think group to help debug this code which has baffled the top minds of the company:

    protected function getValue () {
        return this.getValue();
    }
    

    "We can't understand what's wrong. Whenever we run it, we get a stack overflow error. Any insights, being the world-class coder that you are?"

  • Ollie Jones (unregistered)

    This wtf is bigger than Rupert. It's the lonesome-hero model of engineering. It may be true that some programmers are 10x more productive in a particular day's work than others. But world-class programmers? There are ten of them. Chances are you and I are not among them. Let's get back to work!

  • (nodebb)

    Lovely, lovely. I just think he named the methods incorrectly. It says "get street", whereas it's clear the method returns the provided street. So it should be named "returnTheSameStreet". Then, the naming matches the function, and we can all see that it's bulletproof and will pass any testing you through at it. It becomes world class code!

  • (nodebb)

    Ahhh. but what could derived classes do with them... Side note, designing for derivation is HARD. Writing your base class so that unknown programmers can use it effectively as a base class - and still guarantee that their classes will not break your contract takes LOTS of work.

  • Steve (unregistered)

    Team Lead: You can't hard-code values, you have to populate them through a method.

    Rupert: Stand back and marvel people!

  • Robin (unregistered)

    Unsurprising. As soon as anyone considers themself "world class" to the extent they feel the need to tell everyone else about it on a regular basis, you can basically guarantee that they'll be average at best, and most likely produce the kind of rubbish shown here. I assume it's related to the Dunning Kruger effect, as well as the fact that people who have that sort of opinion of themselves obviously see no need to listen to others' criticisms of their work!

  • Nigel (unregistered)

    Let's give this world-class programmer just a little credit. The code has potential for easily adding some useful extra functionality. For example, the call getCity("LA") could be configured to return "Los Angeles", and so on.

  • Luke (unregistered)

    Why was there no code review to mention this, no pull request to decline?

  • DQ (unregistered) in reply to Nigel

    Are you Rupert?

  • (nodebb)

    Thanks, Bro, for this great recommendation of the most perfectest world-class coding style! I'll hurry on to introduce it in my team. I am sure that Kevin will enjoy it.

  • Brian (unregistered) in reply to TheCPUWizard
    Side note, designing for derivation is HARD. Writing your base class so that unknown programmers can use it effectively as a base class - and still guarantee that their classes will not break your contract takes LOTS of work.

    But most of the time, the base and derived classes are part of the same codebase, so new parent properties/methods can be added as needed rather than trying to predict the future up front. Or as is frequently the case in my company, just take the functions that have been copy-pasted into half a dozen classes and refactor them into (or create) the base.

  • (nodebb)

    Well, at least he didn't cast and re-cast into and out of some "proprietary" encryption nonsense...

  • (nodebb) in reply to Luke

    Why was there no code review to mention this, no pull request to decline?

    Have you ever worked with a Rupert? If his company instituted code review, Rupert would immediately come to the conclusion that the entire world was out to ruin his reputation by logging trivial code review rebukes. His "ironclad proof" would be the fact that the product does not exhibit a demonstrable bug.

    Then, everyone would be sent to sensitivity training, and a director would sit in on all future code reviews to ensure that no one ever criticized anyone else's work, ever.

  • Sole Purpose Of Visit (unregistered) in reply to Mr. TA

    Actually I believe the perfectly cromulent naming convention, given generics, would be:

    public T SameOldSameOld<T> (T $thingie)
    {
          return $thingie;
    }
    

    The great thing about this is that it allows for overloads and side effects, should you need them in the future. Which in this code base I assume you would.

  • (nodebb)

    Let us now praise Jitters.

    Nah. They're usually a sign that I've had my sixth cup of coffee a bit too early in the day.

  • Kleyguerth (github) in reply to Prime Mover

    "Oh that's so obvious, you are supposed to pass the value by parameter and then return it! See? This is why you need a world class programmer like me! Can we discuss my raise now?"

  • Loren Pechtel (unregistered) in reply to Nigel

    |Let's give this world-class programmer just a little credit. The code has potential for easily adding some useful extra functionality. For example, the call getCity("LA") could be configured to return "Los Angeles", and so on.

    That was my first thought--this is either to allow for future data massaging (and maybe even present massaging---the functions that actually do something might not have been included because they aren't WTFs) or the remains of past data massaging.

    If it were truly a WTF to support this we wouldn't see c# supporting {get; set;} declarations.

  • (nodebb)

    He learned long ago that global variables are wrong, you should use parameters and return values.

  • (nodebb) in reply to Sole Purpose Of Visit

    One minor detail and I hate to be nitpicky like this: the original code had the method decorated as "protected", whereas yours is "public". Our world class programmer took care of security, too!

  • p (unregistered)

    As TheCPUWizard hinted at, couldn't these methods actually serve some useful purpose in an abstract baseclass? Derived classes could override them to implement validation or transformations of the various fields.

  • Sole Purpose Of Visit (unregistered) in reply to Mr. TA

    Darn, I missed that.

    I am no longer world class. I might even struggle to be small continent class.

  • Sole Purpose Of Visit (unregistered) in reply to Barry Margolin 0

    Now, to be absolutely fair, this is a very good example of "fixed point theory" in practice.

    Not an especially useful one. But you can't deny that it is a wonderful way to describe a fixed point, within the functional domain, by mapping the point onto itself.

  • (nodebb) in reply to Barry Margolin 0

    (a) Hide your globals private to some scope. (b) Return pointers to the through a function. (c) Enjoy the pain of having globals, but now they even have different names i each function that accesses them.

    Addendum 2021-06-02 17:44: *to the globals. Autocorrect on my iPad recently likes to eat words.

  • Twither (unregistered)

    I feel like "world-class coder" is the kind of title programmers assume for themselves the first time they break through a bottleneck of understanding and start to see beyond the code. Their eyes have been opened for the first time, and they naturally assume everyone else's eyes are closed, just as theirs were a moment before. Relative to where they were, it really is the difference between the heavens and the earth... but there are many more such moments to come.

  • (nodebb)

    It HAS potential, doesn't it:

    protected function getCity($city) { if (cityService.countPubs($city) < 10) { throw new BoringCityException(); } if (cityService.isDictatorship($city)) { throw new YouDontWantToGoThereException(); } return cityService.translate($city, getMyLocale()); }

    Addendum 2021-06-03 03:54: It HAS potential, doesn't it:

    protected function getCity($city) {
     if (cityService.countPubs($city) < 10) {
        throw new BoringCityException();
     } 
    
      if (cityService.isDictatorship($city)) {
        throw new YouDontWantToGoThereException();
      }
    
      return cityService.translate($city, getMyLocale());
    }
    
  • (nodebb) in reply to jonhaug

    That would leave the issue of getCity being a bad name for the functionality. I struggle to think of a good name for it though, which is probably a bad sign.

  • ma (unregistered) in reply to jonhaug

    Don't throw unexpected Exceptions from your subclasses!

  • Dunning-Kruger (unregistered)

    I'm surprised nobody has picked up on this application of our study about this. Rupert was our inspiration for our theory that some people are so clueless that they can't even understand the fact that they are clueless.

  • Eaten by a Grue (unregistered) in reply to Robin

    You're absolutely right that somebody claiming to be a top-notch programmer should be immediately suspect.

    I remember when I encountered one such "brillant" programmer who checked in code he claimed was production-ready, but he'd fouled up enough times that I was being asked to QA stuff before we pushed it live. So I did, and immediately encountered his syntax error on code he'd wanted to be on our live servers right away. In my conversation with the head of development, who had up until now been generally supportive of this guy, I noted that if he'd gone so far as to actually run his code before sending it, he would have found this problem immediately.

    He was fired soon afterwords.

  • (nodebb)

    It would be nice if "comments held for moderation" would be showed in the sequence at the time they were allowed through, not at the time they were posted :/ Hard to find comments I missed that way.

  • David Mårtensson (unregistered)

    Its the same in many languages that instance variables can be accessed, they are just another scope level. C++ and C# allows the same.

    In C# you can use this prefix to distinguish between a local variable or function argument and an instance variable, but it is not required.

  • Chris (unregistered)

    World class apparently means averaging out the programming ability of the entire global population.

  • (nodebb) in reply to Chris

    Sometimes "I don't know how to do this" constitutes higher ability than trying.

  • grg12 (unregistered) in reply to Nigel

    a few years ago i worked on some legacy code written in C - original code used "structs" to describe sound and graphic data and set of access funcions to control playback, modify graphic and so on. At some point project structure changed - some asset were moved to "display server process" and all access functions modified to automatically recognise remote assets and and use interprocess communication instead of manipulating local variables. Migration SHOULD be quick and easy since clients call convention didn't change at all - except some programmers didn't use access functions, cause "it only modifies one member variable anyway"... Finding and fixing "optimised" staments in 100's of legacy modules was not fun.

  • Jay (unregistered)

    We had a world class programmer at a company I worked for once. When he quit, he refused to tell anyone where he had gotten a new job, because, he said. He didn't want anyone at his current job calling the new place and badmouthing him. Why would we do that?, I asked. If we convinced them to rescind the job offer, you'd stay here.

  • Jay (unregistered)

    Ah, I see the problem. Clearly a more enterprises solution would be to write:

    Private String getAnything(String anything) {Return anything;}

    Public String getCity(String city) {Return getAnything(city);}

    Public String getStreet(String street) {Return getAnything(street);}

    Etc

Leave a comment on “A World Class Programmer”

Log In or post as a guest

Replying to comment #528147:

« Return to Article