I came across a question earlier where someone asked how to create an array list with multiple object types (Create an ArrayList with multiple object types?).
The easiest solution is to create a list of objects, but many people mentioned in the replies and comments that using a list of objects is not a good idea, and might even be a code smell. The preferred solution by consensus seems to be a new class that takes in the different types as its parameters.
I can see why creating a list of objects would be problematic, as it's too easy to forget what order the objects are in, what type they are, etc.
I have seen this problem before in code that I've worked with, so I know it's a common blunder.
I was wondering if there is a name for it. Most code smells I've come across have a name, but I don't recall coming across one that described this one. I tried to look it up, but couldn't find anything.
Objects doesn't strike me as a code smell. Downcasting them does, and if you're doing anything with them that can't be done with a plainObjectthat's what you're going to have to do.