• Rast (unregistered)

    This post contains strings for all possible posts that WTFers could wish to make.

    Oh, and Frist!

  • Martin (unregistered)

    String First='Second" print(first)

  • (cs)

    public static String _COMMENT = "comment";

  • Roadhead (unregistered)

    This is obviously going to save you tons of time in an IDE that has code completion, because you would only have to type '_W' and then CTRL+SPACE and then use the down arrow to scroll through the choices and pick '_WY'. This is obviously much more efficient than just typing 'WY' - DUH.

  • (cs)

    All you really need is the correct indices to get the proper substring out of public static String _PI_COMPLETE.

  • derfy (unregistered)

    function makefirstpost() { $f = 'f'; $i = 'i'; $r = 'r'; $s = 's'; $t = 't'; $ep = '!';

    $captcha = 'conventio';

    $return = $f.$r.$i.$t.$ep; return $return }

  • Anders Hesselbom (unregistered)

    What are the criteria for a number to qualify as a constant? Even though the file had many constants, there are even more numbers left to add to the file. I hope they look in to this. ;-)

  • (cs)

    public static String _GREATER_THAN_OR_EQUAL14 = ">=14";

    This is just good practice. It completely removes the ambiguity of the magic number 14 in your code. _GREATER_THAN_OR_EQUAL14 is much shorter than typing out >=14 EVERY TIME you want to do a comparison to 14. This will also ensure that I don't punch the programmer in the ear when I find out who wrote it.

  • Zap Brannigan (unregistered)

    A frustrated COBOL programmer acting out?

  • Shoot Me! (unregistered)

    Looks like someone had their IDE setup to error on all non-constant Strings in the code. If that's not the case, then the insanity is truly setting in.

  • Simple User (unregistered)

    _W _T _F

  • Yep (unregistered)
    public static class _1337 {
        public static String _THIS = "THIS";
        public static String _STORY = "STORY";
        public static String _WAS = "WAS";
        public static String _LAME = "LAME";
        public static String _PERIOD = ".";
    }
  • (cs) in reply to Martin
    Martin:
    String First='Second" print(first)

    compile error.. mismatched quotes

  • Dirk (unregistered) in reply to pitchingchris
    pitchingchris:
    Martin:
    String First='Second" print(first)

    compile error.. mismatched quotes

    and even when fixed: Symbol not found: first

  • krupa (unregistered)

    I'm calling "Shenanigans" on this one. No one would work with shit like this.

    private _2 whoTheHellKnows = new _2();
    Yeah, right.
  • (cs)

    <%=class_1821._TDWTF_COMMENT %>

  • Marc (unregistered)

    The real WTF :

    The sophisticated incrementing system of naming classes leaves us with a class name like '_1641' when there are only 552 classes.

  • (cs)

    And to top it off, the "constants" aren't even constant...

  • Germán (unregistered)

    Fear not... since they're not constants (final keyword), you can assign the right value afterwards:

    _1641._AK = "AK";

    And everybody happy! Right?!

  • VV (unregistered) in reply to akatherder

    I think that refactoring could make it right:

    public static String _GREATER_THAN_OR_EQUAL14 = _GREATER_THAN_OR_EQUAL + _215._14;

  • (cs)

    In the precursor of my current project (huge financial app) there was a "Constants class" like that too (actaully a "constants interface", a practice considered a WTF in itself by some, though I don't see it as all that bad). The contents weren't as idiotic as this, but it still was (or became) a huge WTF. Since every single one of the about 5000 classes in the project used that interface, or used another class that used it, a full rebuild of the entire project (automatically if eclipse was set up that way) was triggered whenever you had to add a new constant. It took about 15 minutes on a brand-new workstation.

  • (cs) in reply to Zap Brannigan
    Zap Brannigan:
    A frustrated COBOL programmer acting out?

    It must be. COBOL is the only language that I know of where it's possible to have a negative zero. (And, yes, it does not equal zero!)

    public static String _AUTO_STTS_OIE = "-0";

  • APH (unregistered)

    Am I the only one who caught the Zork reference? Seriously, isn't ANYBODY going to be eaten by a grue?

  • Tom (unregistered) in reply to akatherder

    The REAL WTF here is that the author didn't use the constants in defining the other constants. He should have written them like this:

    public static String _GREATER_THAN_OR_EQUAL14 = _GREATER_THAN_OR_EQUAL + "14";

    That's ELEMENTARY software engineering!!

  • BlueCollarAstronaut (unregistered)

    Personally, I think that's pretty awesome. I can never remember which symbol is greater than and which one is less than (The aligator eats the bigger number, right?). So this way, I just have to remember _5._GREATER_THAN...or as a backup -- in case one forgets _5 -- there's also _83._GREATER_THAN.

    What could be simpler than that?

    Although, it would help if someone had added something like the following: _9347._Captcha = "feugiat";

  • (cs) in reply to derfy
    derfy:
    function makefirstpost() { $f = 'f'; $i = 'i'; $r = 'r'; $s = 's'; $t = 't'; $ep = '!';

    $captcha = 'conventio';

    $return = $f.$r.$i.$t.$ep; return $return }

    ... Did you just inflict PHP on an unsuspecting crowd? That's 15 Hail Mary's!

  • Blackice (unregistered)

    public static String _EQUAL = "=";

    Depending on the language used, I forsee problems with this...

  • vman (unregistered) in reply to APH
    APH:
    Am I the only one who caught the Zork reference? Seriously, isn't ANYBODY going to be eaten by a grue?

    Of course not, they're in a sunny meadow. Everyone knows that the grue only eats you if you enter a dark area without a light.

  • (cs)
    public static class _1641 { public static String _AB = "AB"; public static String _AK = "AB"; // *SNIP* public static String _WY = "WY"; }

    I'll spare you the remaining lines of the 16,519 line file. But suffice it to say, if there's a string you need, it appears somewhere in one of the five hundred and fifty two classes.

    552 classes, incrementally numbered, so around 1090 must have been deleted - they really should have finished what they started and got rid of the remaining 552.

  • some coder (unregistered)

    public static string _RANDOM_USER_COMMENT = "WTF Batman?!?";

    seriously though, this looks to me like a perfectly reasonable "best practice" that was enforced by a clueless idiot who was promoted after the actual designer left.

  • Anonymous Cow-Herd (unregistered)

    System.out.println(_1269._F+_1269._I+_1269._R+_1269._S+_1269._T);

  • (cs)

    public static String _AK = "AB";

    This is not a bug -- actually, it demonstrates the power of the technique. Obviously, new application needs have necessitated redefining the string "AK" to "AB". This way it only has to be changed at one place. Duh.

  • jared (unregistered) in reply to akatherder

    No, good practice would be defining a constant with value 14 whose name indicates what it means. _GREATER_THAN_OR_EQUAL14 is no different than typing >=14. Neither tells you anything about why you are comparing to 14.

  • EatenByAGrue (unregistered) in reply to APH
    APH:
    Am I the only one who caught the Zork reference? Seriously, isn't ANYBODY going to be eaten by a grue?

    Yeah, it really sucks when that happens.

  • (cs) in reply to Walleye
    Walleye:
    Zap Brannigan:
    A frustrated COBOL programmer acting out?

    It must be. COBOL is the only language that I know of where it's possible to have a negative zero. (And, yes, it does not equal zero!)

    public static String _AUTO_STTS_OIE = "-0";

    Java's Double class treats -0.0 and 0.0 as different numbers.

  • Shoot Me! (unregistered) in reply to Someone You Know
    Someone You Know:
    Java's Double class treats -0.0 and 0.0 as different numbers.

    The more you know! (Shooting star going across the screen)

  • JUST ANOTHER WTF (unregistered) in reply to gabba
    gabba:
    public static String _AK = "AB";

    This is not a bug -- actually, it demonstrates the power of the technique. Obviously, new application needs have necessitated redefining the string "AK" to "AB". This way it only has to be changed at one place. Duh.

    Actually I just think it means that whoever they were trying to mail stuff to moved from Arkansa to Alberta. So not a WTF

  • (cs)
    public static int _5 = 6; // 5;

    Whee!

  • ydrol (unregistered) in reply to Yep
    public static class _1337 {
    public static String _PERIOD = ".";
    

    }

    public static class _1337_UK extends _1337 { public static String _FULL_STOP = _PERIOD; }

  • (cs)

    One of the great things about this site is having the opportunity to educate young developers as they start out on their career.

    Constants are something you should use to make your code more readable, and it is a good idea to keep them all in a central location.

    I am not a Java programmer (although I am sure it would be easy for me), but I have chosen to go into the more lucrative field of Visual Basic, since it is higher demand and has more room for promotion. Anyways...

    In VB, I like to put constants anywhere that the value could change. For example, in our ordering system, I have all the sales tax codes as constants, so if they change, all I need to do is whip open Visual Studio, make one change, recompile and I'm finished, no big deal.

    If you are a DBA, and not a developer, you might ask why do I store them as constants rather than in a database (and beleive me I have had to fight this fight), the answer is it takes less time to re-compile my application, than submit a database change request and wait for the DBA union to run my update script.

    So the lesson I want to leave you with, it is often best to store data as constants or variables in code that YOU CONTROL than it is to store it in a database that you have no control over.

  • (cs)

    public static String _MEANING_OF_LIFE_UNIVERSE_EVERYTHING = "42";

  • Socket (unregistered)

    _WY indeed...

  • (cs) in reply to ydrol
    ydrol:
    public static class _1337 {
    public static String _PERIOD = ".";
    

    }

    public static class _1337_UK extends _1337 { public static String _FULL_STOP = _PERIOD; }

    class base {
      public static String _5 = "5";
    }
    
    public class sub extends base {
      static {
        _5 = "6";
      }
    
      public static void main(final String argv[]) {
        System.out.println(base._5);  // -> 6
        System.out.println(sub._5);   // -> 6
      }
    }
    
  • Gerrit (unregistered) in reply to Walleye
    Walleye:
    Zap Brannigan:
    A frustrated COBOL programmer acting out?

    It must be. COBOL is the only language that I know of where it's possible to have a negative zero. (And, yes, it does not equal zero!)

    public static String _AUTO_STTS_OIE = "-0";

    On IBM mainframes decimal and packed decimal data types can represent negative zero. Other languages used on mainframes can do it as well. And Python can do it too:

    a=-0.0 print a -0.0

  • James O'Boston (unregistered) in reply to TopCod3r

    How about the use case where I control both the DB and the code, but am just too lazy to make the change in the DB?

    TopCod3r:
    One of the great things about this site is having the opportunity to educate young developers as they start out on their career.

    Constants are something you should use to make your code more readable, and it is a good idea to keep them all in a central location.

    I am not a Java programmer (although I am sure it would be easy for me), but I have chosen to go into the more lucrative field of Visual Basic, since it is higher demand and has more room for promotion. Anyways...

    In VB, I like to put constants anywhere that the value could change. For example, in our ordering system, I have all the sales tax codes as constants, so if they change, all I need to do is whip open Visual Studio, make one change, recompile and I'm finished, no big deal.

    If you are a DBA, and not a developer, you might ask why do I store them as constants rather than in a database (and beleive me I have had to fight this fight), the answer is it takes less time to re-compile my application, than submit a database change request and wait for the DBA union to run my update script.

    So the lesson I want to leave you with, it is often best to store data as constants or variables in code that YOU CONTROL than it is to store it in a database that you have no control over.

  • (cs) in reply to jared
    jared:
    No, good practice would be defining a constant with value 14 whose name indicates what it means. _GREATER_THAN_OR_EQUAL14 is no different than typing >=14. Neither tells you anything about why you are comparing to 14.
    NO SHIT, SHERLOCK.
  • Aris (unregistered) in reply to TopCod3r

    I'm not sure to agree with you. Constant shouldn't be in a central location. They should be at a place where they make sense and where you expect to find them. If your projets implements HTTP and FTP, the HTTP and FTP constants must be defined in their respective classes. If your company connects to different servers to sell potatoes, the server default port should be defined private in StoreSocket and the potato price should be defined in Potato (or Item, depending the level of OO you implement).

  • BK (unregistered)

    "OK, now open your eyes. Which code file was it? If you're like me, then it was a preliminary collection of constants and enumerations based on the business requirements"

    I'm happy to report that I am not like you and I would never had started with such a file. Most likely I would have never introduced it to the project. If someone else would try doing so, I would actively fight the idea, because it introduces coupling between otherwise unrelated parts of the software. Unless of course, these parts are already related (but then we are not talking about centralized collection of constants and enumerations anymore).

    Lots of (lost) programmers love to start new projects, but only to scribble some ideas on the clean canvas, with very little thought given to actual design.

  • Buddy (unregistered) in reply to Charles400

    Back in my hobby days, I once wrote a game where I needed a constant that tied everything together. It had to do with size of int, extent of the game area, color depth of the screen, speed of the processor and user's angle of view. If memory serves me correct, the constant was in the high teens. Good times.

  • Bob (unregistered)

    Beautiful example of constant abuse - one that negates almost every benefit of constants. I used to use 'constant interfaces' in Java because I saw the technique used in the Java framework and assumed it was an acceptable practice. It wasn't, as it turns out.

Leave a comment on “Constantly Expanding”

Log In or post as a guest

Replying to comment #:

« Return to Article