• (disco)

    Ultimate frist!

    6am UTC is quite early, indeed.

    Long live the power of notifications!

  • (disco) in reply to aliceif
    aliceif:
    Ultimate frist!

    6am UTC is quite early, indeed.

    Long live the power of notifications!

    Congratulations!

    Filed under: I shouldn't have gone to the "Official Likes Thread" straight away...

  • (cs)

    The HTML is nicely borked.

  • (disco) in reply to faoileag

    I hate you guys

  • Hannes (unregistered)

    Remy accidentally the whole thing. Maybe he should've used CONSTANTS to create the source code?

  • Globgor (unregistered)

    They could be there to facilitate translation (including into another dialect of SQL...)

  • (disco)
    public static final String CALL = "{CALL ";  
    public static final String FUNCTION_CALL = " {? = call";  
    public static final String END_CALL = "}";  
    

    Hmm. Reminds me of http://c-faq.com/cpp/slm.html

  • cyborg (unregistered)

    This should be The CONSTANT Gardener with the obvious metaphor being that this is cutting through the overgrown weeds that were put there by another gardener who thought this is what a garden was supposed to have in them.

  • Dmitri (unregistered)

    Come on... who hasn't done this?

  • (disco)

    Hmm, the bot has got a bit excitable again.

  • (disco)

    I wonder what would happen if they release a non-english version someday ...

  • (disco) in reply to Cursorkeys

    SETTLE DOWN PAULA! We don't have your beans!

  • (disco)

    Well that's annoying. The space for the 'like' text isn't pre-allocated so as each post gets liked it jiggles the screen around as the size changes. Great idea for a floating design.

  • (disco)

    Does anybody know if this topic is visible yet? I'm not sure if it will be displayed in topic lists

  • (disco)

    public static final String NUM_TIMES_TO_MAKE_ARTICLE_VISIBLE = "BRILLANT!;

  • (disco)
    jaloopa:
    Does anybody know if this topic is visible yet? I'm not sure if it will be displayed in topic lists
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.
    PaulaBean:
    This topic is now visible. It will be displayed in topic lists.

    There's no way of knowing for sure.

  • (disco) in reply to Cursorkeys
    Cursorkeys:
    Well that's annoying. The space for the 'like' text isn't pre-allocated so as each post gets liked it jiggles the screen around as the size changes. Great idea for a floating design.

    Now wait and watch the likes topic when someone catches up on likes and you'll see the page moving while you wait - because it updates it pretty much live. Great fun if you're typing at the same time and what you're typing is scrolling off the screen.

  • (disco) in reply to Keith
    Keith:
    There's no way of knowing for sure.

    I disagree: https://www.youtube.com/watch?v=aCbfMkh940Q

  • Hannes (unregistered)

    Holy cow, I just noticed there's something vital missing here!

    public static final boolean BOOLEAN_TRUE = true;  
    public static final boolean BOOLEAN_FALSE = false; 

    What about

    public static final boolean BOOLEAN_FILENOTFOUND = FileNotFound

    ?

  • (disco) in reply to aliceif
    aliceif:
    I wonder what would happen if they release a non-english version someday ...
    They would only have to change the strings in one place and not all over the codebase! Clever, huh?
  • (disco) in reply to Cursorkeys
    Cursorkeys:
    Well that's annoying. The space for the 'like' text isn't pre-allocated so as each post gets liked it jiggles the screen around as the size changes. Great idea for a floating design.
    Welcome to Discourse...
  • (disco)

    TBH, not all of the strings are ridiculous as A_TEXT = "A". The abbreviations for package names and procedures are not so bad, and some strings might occur more than once in the code, making replacement easier. It's not the preferred way to do I8N though.

  • (disco)

    Ok, just my 2% on yet another "make everything a constant" article.

    Why public static final String ZERO = "0"; is definitely overdoing it, the code featured is what you get if your coding rules include something like "magic numbers or string literals in the code are not allowed".

    You ask for accumulating stuff in one place as consts, you get it.

    The second reason such code exists (been there, done that, still do occassionally) is when you work in an environment where demands like "I don't like the sentence in the button there, it contains to many "o"s. Change it!" are made regularly and have to be dealt with by whoever is available.

    In that case, you const all string literals and place them in one well-known file simply to make life easier for the poor fellow tasked with changing the text.

    So, some minor wtfs in the first part, but I don't really see the long list of const'ed string literals as a wtf. Sorry.

  • (disco)

    TRWTF

    public static final String secretKey = "mE3BrW5B";

    Not so secret any more :-)

  • anonymous (unregistered)

    And this is what happens when you're typing HTML in a richtext editor and it sticks <p> tags in places where they shouldn't be.

  • (disco) in reply to faoileag
    faoileag:
    I don't really see the long list of const'ed string literals as a wtf

    Sorry to disagree man, but that's what resource files are for. Java must have an equivalent (only more enterprisey). In fact, yes it does.

    Constants are a simple/low tech/crude way of doing things, but once you have to support multiple languages you're screwed unless you're going to branch the file, or come up with a more complex solution, in which case you may as well just use resource files anyway.

    The other advantage resource files have is that you can make spelling changes without needing to recompile the whole application.

    If anyone tried to check something like that in here, I'd slap them up the side of the head and make them wear the cone of shame for the rest of the week.

    John_Imrie:
    public static final String secretKey = "mE3BrW5B";

    Not so secret any more

    Good spot old boy!!! I would double like this if it were still possible.

  • (disco)

    Oh man... I just can't unsee this.

    And as someone else pointed out, what about resource files? I haven't done any Java since 1996, but in .NET that's where we put all our text (especially since the applications we write have to be multilingual).

  • (disco)
    public static final String SPACE = "&nbsp";  ```
    Something is missing there...
    
    

    public static final String disposition = "Content-disposition";
    public static final String dispositioninline = "inline; filename="";
    public static final String conappndone = "/";
    public static final String conappndtwo = """;
    public static final String contypetwo = "application/octet-stream";
    public static final String dispositionattachment = "attachment; filename="";

    The associated code must be fun to read.
    
  • (cs)

    Every noob programmer go through initiation ritual. They will create constants that will muddle the code.

  • (disco)

    It is my understanding that this topic is now visible. It will be displayed in topic lists.

  • (disco) in reply to Michel_Renaud
    Michel_Renaud:
    And as someone else pointed out, what about resource files? I haven't done any Java since 1996, but in .NET that's where we put all our text (especially since the applications we write have to be multilingual).

    That's also how you'd do localisation in Java. Except in this case it seems, where you localise by editing the secret key database insert appropriate constant in this source file.

  • anonymous (unregistered)

    This looks kind of like the result of a heavy-handed coding practice of NO LITERAL CONSTANTS ALLOWED IN THE SOURCE CODE, ALL CONSTANTS MUST BE NAMED, NO EXCEPTIONS.

  • (disco) in reply to dkf
    dkf:
    secret key database insert appropriate constant in this source file

    I still can't believe that, what a dumbass!!1!1!


    Filed under: wait, was this taken from the Discocourse source?

    P.S. Discocource source is quite fun to say

    P.P.S. I know it couldn't be from the Discocourse source because it's the wrong language, but that'd just be a barrier to making fun of Discocourse

  • (disco)

    Am I the only one who wonders if the author of this code ever heard of abstract classes?

  • (cs) in reply to Dmitri
    Dmitri:
    Come on... who hasn't done this?

    +1 QFT.

  • (disco) in reply to faoileag

    The other advantage resource files have is that you can make spelling changes without needing to recompile the whole application.

    I'd say that's a disadvantage.

    http://xkcd.com/303/

  • (disco)

    printf(SUBMENU_WHOSON, "FRIST");

  • (disco) in reply to RichP
    RichP:
    printf(SUBMENU_WHOSON, "FRIST"); public static final String FRIST_TEXT = "54th"; printf(SUBMENU_WHOSON, FRIST_TEXT);
    There. FTFY.
  • (disco)

    That "class Constants" is truly amazing. We have COBOL copybooks like that...but then you either do that in COBOL or else you define the constants in every program...which, oddly enough, has a downside...

    But it's pretty clear that the creator of "class Constants" was a programmer from some environment such as COBOL, because there are much more logical ways to store constants in an OO systems.

    Also, I think you should do an article on how constants are used. Take this constant:

      05  EMPLOYEE-ROW-ACTIVE    PIC X(1) VALUE 'Y'.
    

    Ok. So then why do we have...

      EXEC SQL
           SELECT ...
           FROM PAYROLL_PERIOD_TABLE
           WHERE ROW_ACTIVE = :EMPLOYEE_ROW_ACTIVE
    
  • (disco) in reply to CoyneTheDup

    I was all kinds of going to read your post, but then I saw COBOL and SQL in the same block of code. It supports that?

    Next thing you know it's going to be supporting things like variable length strings.

  • (disco) in reply to xaade

    Well if it didn't I guess the most respectable bank systems would not have databases at all! For shame!

  • (disco) in reply to agbeladem

    Oh man.

    The COBOL I used had a flat file database backend. Maybe it was even proprietary.

    So I had no way of knowing.

  • (disco)
    <div class="ArticleBody">
      <p>
        <pre>
          <code>
      </p>
          </code>
        </pre>
      <p>
    </div>
        HTML is hard difficult.
      </p>
  • (disco)

    It's not enterprisey enough. The constants should be base64-stored in elements of an XML document, printed out, placed on a nice, clean wooden table, photographed, scanned, attached to a Word document, emailed, screenshotted, and finally stuffed into BINARY fields on a database.

  • (disco)
    public static final string TL_DR = "tl;dr";
    
  • (disco)

    I feel like I need to bill someone after reading that. Bonus points for

    public static final String MW_FG_TILDE_X = "X~";
    
  • (disco)

    Is @PJH awake yet?

  • (disco)

    For the date ones, I can understand what they were attempting, but they were a bit off.

    DATE_TIME_PATTERN_FULL isn't really descriptive towards the usage, only what it is, which should be easily identifiable from looking at the date format specifier. But if you have something like FILENAME_DATETIMESTAMP, it makes sure that you have a consistent approach to naming files based on dates/times.


    And there's no doubt that FOOTER_TIMESTAMP is a WTF, since it's either used once in a footer snippet of code, or it's copypasta'd in every place that has a footer.


    Also, what happened to H, J, K, L, N, O, Q, U, V, W, X, Y, and Z?


    public static final String JAVA_EXCEPTION_CODE = "9999"; ..........because I think of magic numbers when working with exceptions, not errors. I can't remember why these are a WTF in Java, I just remember that people always complain about them, and make me glad that I never touch Java.

  • (disco) in reply to chubertdev

    Been awake for ages. Why?

  • (disco) in reply to PJH

    This topic needs a bit of cleanup.


    public static final String MENU_RESERVATION = "Reservations";  
    public static final String SUBMENU_ARRIVALLIST = "Arrivals List";  
    public static final String SUBMENU_ARRLISTWITHCC = "Arr List with CC";  
    public static final String SUBMENU_CCPROCESSING = "CC Processing";  
    public static final String SUBMENU_BWIEXTRAFORM = "BWI Extra Form";  
    public static final String SUBMENU_PROPERTYTOPROPERTY = "Property-to-Property";  
    public static final String SUBMENU_RESVBOOKEMPLOYEERATE = "Book Employee Rate";  
    public static final String SUBMENU_RESVTRANSACTIONLOG = "Transaction Log";  
    public static final String SUBMENU_RESVTRANSLOGWITHCC = "Trans Log with CC";
    

    Is this for the Baltimore airport? o_O


    EDIT: probably not, unless it's just a European developer for BWI. public static final String MENU_BESTCHEQUECOMM = "BestCheque Commissions";

    Or it could be 'Murica: public static final String MEM_SRCH_PROMO = "NASCAR";


    public static final String MW_FG_BWR_ERROR = "Exception occured during submission."; #WHY DOES NO DEVELOPER KNOW HOW TO SPELL THIS!?!?!?!!?


    public static final String E = " E ";

    shouldn't that be SPACE_E_SPACE?


    public static final String MODIFY_RATES_UI_NBSP = "&nbsp;"; Much different than any other &nbsp;.


    public static final String REPORT_FORMAT_ONE = "01";  
    public static final String FORMAT_ONE = "1"; 
    

    What if you need REPORT_FORMAT_TWO?


    public static final String DELIMITER_EQUAL_TO = "="; Silly developer, using Java, it should obviously be: public static final String DELIMITER_EQUAL_TO = "==";


    public static final String SPACE_160 = "&#160;"; So if the space character suddenly changes and becomes &#159;, will the code need to be refactored to SPACE_159?


    public static final String NULL = "null";  
    public static final String LOGOUT_URL_KEY = "LOGOUT_URL"; 
    

    I like how both of these are strings when they should simply be values. NULL should be null, not "null", and I assume that the logout URL is referenced as something like Config[LOGOUT_URL_KEY], but that's just going a bit too far.

Leave a comment on “The Constant Bomb”

Log In or post as a guest

Replying to comment #:

« Return to Article