Hacker News new | ask | show | jobs
by arethuza 4939 days ago
Most amusing I've seen was Java code that was rather over zealous about DRY and no-string-literals in code (i.e. all strings had to be define as constants).

This resulted in code like:

   url = HTTP + COLON + SLASH + SLASH + WWW + DOMAIN_NAME + DOT + COM;
based on lots of definitions like:

   public final static String COLON = ":";
   public final static String SLASH = "/";
   public final static String DOT = ".";
   public final static String COM = "com";
[Apologies if this contains any Java syntax errors, I pretty much stopped using Java soon after this experience]

Also I've just realised that I'm really glad Java doesn't have a standard pre-processor - truly evil things would then have been possible <shudder>

2 comments

COLON + OPEN_BRACKET
Hah. It's funny how nobody thought to create a simple static utility function which converted a domain-name to a fully-qualified .com URL.