• Rob (unregistered)

    Of course the entire thing can be replaced by just two lines:

    String[] MM_fields = { "phone", "value", "organization", "value", "last_name", "value", "first_name", "value", "password", "value", "email_opt_in", "value" },
    String[] MM_columns = { "phone", "',none,''", "organization", "',none,''", "last_name", "',none,''", "first_name", "',none,''", "password", "',none,''", "email_opt_in", "none,1,0" };
    
  • TheCPUWizard (unregistered)

    IF I recall, there was an issue with the static initialization of arrays... but it has been a while...

  • Naomi (unregistered)

    Java's strings have a split method, but it takes a regex. What do you bet they tried "[wonky pipe string]".split("|") and switched to the StringTokenizer approach after getting errors about an unescaped pipe character? (Not that using the right method for the job helps much when the job is inherently misguided, but still.)

    (Also, obligatory complaint about clicking through eight captchas.)

  • Bruno Lustosa (unregistered)

    I remember seeing the "MM_" prefix on code generated by Macromedia applications, waaaaaaaaaaay back then, but that's probably not the case here.

  • Álvaro González (github)

    Wasn't mm_ the prefix used by code generation features in Macromedia IDEs or memory is fooling me?

  • Sauron (unregistered)

    By the way, Remy's Law of Requirements Gathering is true. The users do want Excel (or Excel-like) implementations.

  • (nodebb) in reply to Naomi

    @Naomi Yes, but no. OK, the original programmer may well have had a bunch of PatternSyntaxExceptions thrown at him (or even just the compiler complaining about not catching the exception), but that just means that he needed to correctly specify the pattern. ("\\|" or "[|]" would do nicely, if memory serves.)

    But regardless, if we want to avoid flarblisms with the regexness of String.split(...), switching to a tokeniser (don't get me started on a variable called tokens that is of type StringTokeniser), it would surely be better to do it with StringUtils.split(...) or (if using Guava) Splitter.split(...).

    Ref: https://www.baeldung.com/java-split-string

  • (nodebb)

    I'm getting flashbacks to an incident when my German teacher suddenly shaved. People were genuinely distracted by that and couldn't concentrate on class for a bit.

    Remy suddenly changing the profile pic after such a long time has a similarly unsettling effect.

    Speaking of which, my Facebook profile picture is still showing me as a 20yo. Incidentally, also with a ponytail. Incidentally, my face also got a bit rounder since then, though my hair has receded more than with Remy. If I update my profile pic now, anyone who actually looks at it might get a stroke. Good thing, nobody is likely to do that.

  • Naomi (unregistered) in reply to Steve_The_Cynic

    Er, what? Did you miss the part where I called split "the right method for the job", implying that abusing StringTokenizer like this isn't? I'm not defending this code, just speculating as to where it may have come from.

    Also, PatternSyntaxException is unchecked, so the compiler won't complain if you don't catch it.

    Also, it's 2024; can we please get over the assumption that programmers are men already?

  • Res Publica (unregistered)

    As someone from New Zealand: +10 points for referencing Rēkohu.

    An island I'm only fairly sure has access to the internet

  • (nodebb) in reply to Steve_The_Cynic

    (don't get me started on a variable called tokens that is of type StringTokeniser

    According to the docs, StringTokenizer implements Enumeration<Object> so tokens is not really such a bad name for a variable of that type.

    Of course, given that it has String in the name, it seems a bit crazy that the interface is not Enumeration<String> and there are other things that point to the class being a WTF by itself . For example, you can count the tokens left, but you can also change the delimiter on the fly.

Leave a comment on “Under the Sheets”

Log In or post as a guest

Replying to comment #:

« Return to Article