• (nodebb)

    This can be optimized further by parallelism. Start two threads, one will do the for each and set an event, and the other will await the event and increment the count when event is set.

  • Prime Mover (unregistered)

    Every time I see arrays used in Java, I suspect a 3GL programmer who hasn't learned OOP. Similar to when I see ArrayList being used when you should be using an interface (List, probably).

    But hey, at least a grown-up version of iteration has been used, rather than an appallingly inept implementation of a while loop.

    TL;DR: Seen a lot worse.

  • RLB (unregistered)

    And in a sane language, you'd replace (or rather, alias) all those context-less ADTs with defined types. If they'd at least been called cluster instead of ArrayList, you could see where you went wrong.

  • WTFGuy (unregistered)

    Following on @Remy's wrap-up comments. ...

    Agree completely. An organizational (or personal) decision to perform maintenance by the smallest possible increment of change, performed with the smallest possible level of developer understanding, injects a massive dose of technical debt with each beknighted ignorant keystroke.

    In any project with non-trivial scale or lifetime (i.e. all of them, even your personal homebrew toolset), this guarantees eventual abject failure and frustration. It's only by quitting the company before those chickens come home that we each escape the poop we leave in our own nest. Sadly, some other guy/gal has already left plenty of poop in the nest we move into at our new job.

    It's the Circle of Life. Or at least the Circle of WTF.

  • Tim (unregistered) in reply to Prime Mover

    Every time I see arrays used in Java, I suspect an OOP programmer who hasn't learned functional programming

  • Anon (unregistered)

    Is this machine learning? This feels machine learning related, some kind of unsupervised clustering thing. But it's in Java. Why is it in Java?

  • (nodebb)

    I remember writing code like this, but that was in Commodore Basic and non-OOP C, where Max functions were pretty much roll-your-own when it came to arrays. In more advanced languages, arrays, and the like, know how big they are and can tell you; you do not have to remember the size or encode it somehow.

  • Yikes (unregistered)

    As a python programmer (and not knowing much about Java), I'm naturally drawn to the one-liner lambda max of arrays using stream(). We all know, however, that it's ridiculous to loop over so much data with so few lines of code. It's best to add a few extra lines in just for good measure.

  • (nodebb) in reply to Prime Mover

    Similar to when I see ArrayList being used when you should be using an interface (List, probably).

    I took over an application (WebForms, I should have seen this coming) and found a pattern where the data layer returns an ArrayList, filled with instances of the System.Web.UI.WebControls.ListItem. The data layer class even adds a 'new ListItem("--Select--", "select")' to the top of the ArrayList to help the poor UI developer.

  • (nodebb) in reply to RLB

    Please file that JSR today.

  • ram shah (unregistered)
    Comment held for moderation.

Leave a comment on “Counting Answers”

Log In or post as a guest

Replying to comment #:

« Return to Article