Representative Line: Listing Off the Problems

Date:

Share:

Today, Mike sends us a Java Representative Line that is, well, very representative. The line itself isn't inherently a WTF, but it points to WTFs behind it. It's an omen of WTFs, a harbinger.

ArrayList[] data = new ArrayList[dataList.size()];

dataList is an array list. This line creates an array of arraylists, equal in length to dataList. Why? It's hard to say for certain, but the whiff I get off it is that this is an attempt to do "object orientation by array(list)s." Each entry in dataList is some sort of object. They're going to convert each object in dataList into an arraylist of values. This also either is old enough to predate Java generics (which is its own WTF), or explicitly wants a non-generic version so that it can do this munging of values into an array.

Mike provided no further explanation, so that's all speculation. But what is true is that when I see a line like that, my programmer sense starting tingling- something is wrong, even if I don't quite know what.

[Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

Source link

Subscribe to our magazine

━ more like this

Let fires burn, with Selina Tobaccowala

CHERYL KELLOND: I’m driving this huge rig that’s like 35 feet long over highways and bumpy roads. HOFFMAN: That’s Cheryl Kellond, entrepreneur and amateur...

Office manager gets fired and replaced by new hire for 1/4 of their salary, learns his $2,500 bonus is conditional on training his replacement:...

Most employees would take the money and begrudgingly follow orders, but several members of this online community were correct in suggesting that perhaps there...

Red-Dress Halloween Costume Ideas | PS Fashion

While each product featured is independently selected by our editors, we may include paid promotion. If you buy something through our links, we may...

The BEST Nordstrom Anniversary Sale 2019 Picks!

You guys know I've been a huge fan of the Nordstrom Anniversary Sale for the last 6 or so years so I have a...

Clockwise #627: R2-D2 / C-3PO Situation

Support this show Enjoy Clockwise Unwound: Ad-free episodes and an extra Overtime topic every week. #627: R2-D2 / C-3PO Situation October 15th, 2025 · 26 minutes Apple's M5 updates and...