The Daily WTF
Ulvhamne sends us some bad code that, well, I think at this point we should really coin a name for this particular anti-pattern.
@Override public int getNumOfItemsInDataContainer(int parDataId) { int numberOfItems = 0; for (Integer x : myTransactionDataContainerMap.keySet()) { numberOfItems ++; } return numberOfItems; }
This C# function wants to get the number of items contained in a dictionary. To do that, it iterates across the set of keys, and increments a counter. This is instead of using the size field that’s part of the dictionary container.
This one adds a lovely bonus of taking a parameter parDataId, and doing nothing with it.
Marking the parameter as par is an example of so-called “Apps Hungarian”, where the prefix is meant to represent the “logical” datatype or purpose of the variable- semantic information, instead of type information. While marginally better than iDataId, I still hate it. Also, if your
To read the full article click on the 'post' link at the top.