- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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.
Admin
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.
Admin
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.
Admin
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.
Admin
Every time I see arrays used in Java, I suspect an OOP programmer who hasn't learned functional programming
Admin
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?
Admin
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.
Admin
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.
Admin
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.
Admin
Please file that JSR today.