More stuff I couldn't post while at WTF-Inc



  • Generated code can be a good thing. It permits code to be created based upon configurations; just change a config, regenerate, compile and your application works differently.

    Auto-generation of code-stubs can be a time-saver too. However, it implies one must do something with the stubs...

    27,196 methods across ~3,000 classes; all the same (save the name), and per source control, have been untouched since generation more than 3 years ago:

      public void methodXxx(Context c) {
        // Whatever
      }
    


  • @snoofle said:

    Generated code can be a good thing. It permits code to be created based upon configurations; just change a config, regenerate, compile and your application works differently.

    Auto-generation of code-stubs can be a time-saver too. However, it implies one must do something with the stubs...

    27,196 methods across ~3,000 classes; all the same (save the name), and per source control, have been untouched since generation more than 3 years ago:

      public void methodXxx(Context c) {
        // Whatever
      }
    

     

     99% change of TRWTF.. but that still leaves 1%.  I have seen this technique when the empty generated method is in the call stack used as a methodology for providing extension points. With most reasonable / modern languages the empty body will simply be optimized out of existence. Also if there are other methods in the same class that are used, then having consistency may also be a valid rationale.

    But given this is from Snoofle, I concede it is much more likely to be part of the 95% WTF cases...



  • The code stubs are empty except for a comment that reads "Whatever" ? Doesn't sound like something that's in-built into an IDE. Did they all get introduced by the same guy?

    Or, if that's anonymization and the methods aren't actually empty, then are they used anywhere?



  • @Arnavion said:

    The code stubs are empty except for a comment that reads "Whatever" ? Doesn't sound like something that's in-built into an IDE. Did they all get introduced by the same guy?

    Or, if that's anonymization and the methods aren't actually empty, then are they used anywhere?

    not anonymized at all. Never called anywhere. I *think* it was supposed to be an implementation of an interface that was supposed to be implemented by every class, and then got deleted when they realized what a bad idea it was, but they left all the method stubs.


  • @snoofle said:

    Never called anywhere. I think it was supposed to be an implementation of an interface that was supposed to be implemented by every class, and then got deleted when they realized what a bad idea it was, but they left all the method stubs.

    Dead wood, no matter the volume, is at best a minor WTF. It's like searching JK Rowling's recycle bin, uncrumpling discarded pages and making fun of what could have made its way in a story but did not.

    TRWTF is not having a code analysis process running at build time that would point out dead wood. I mean, even Netbeans can spot useless methods, how hard can it be to implement it.



  • @Ronald said:

    TRWTF is not having a code analysis process running at build time that would point out dead wood. I mean, even Netbeans can spot useless methods, how hard can it be to implement it.


    It's impossible in a Turing-complete language which supports reflection. This includes Java.



  • @pjt33 said:

    @Ronald said:

    TRWTF is not having a code analysis process running at build time that would point out dead wood. I mean, even Netbeans can spot useless methods, how hard can it be to implement it.

    It's impossible in a Turing-complete language which supports reflection. This includes Java.
     

     you can take out some rot in most scenarios, i.e. you can make good assumptions about what gets called through reflection

     


  • Discourse touched me in a no-no place

    @pjt33 said:

    @Ronald said:
    TRWTF is not having a code analysis process running at build time that would point out dead wood. I mean, even Netbeans can spot useless methods, how hard can it be to implement it.
    It's impossible in a Turing-complete language which supports reflection. This includes Java.
    But they can highlight/warn about potential unreachable/unused code. You just have to remember that sometimes it is going to be Dead Wrong; that's why you are in charge of the computer, and not the other way round.



  • @dkf said:

    that's why you are in charge of the computer, and not the other way round.
     

    i just do what my computer tells me to.  there is some skill in asking it the right questions... :)



  • @pjt33 said:

    @Ronald said:

    TRWTF is not having a code analysis process running at build time that would point out dead wood. I mean, even Netbeans can spot useless methods, how hard can it be to implement it.

    It's impossible in a Turing-complete language which supports reflection. This includes Java.
     

     

    I hate that people misinterpret "impossible for the general case" to mean "impossible". As long as you aren't analyzing perversely written bytecode specifically designed to confuse a static checker, most static analysis programs will be right nearly 100% of the time.

     And yes I realize that some production code will count as "perversely written bytecode specifically designed to confuse".

     


Log in to reply