nicolasgramlich/AndEngine — Issue #30: Change remove(T) to remove(Object) in IList
Author: s4ke
Created: 2012-02-04 21:09:51+00:00
State: open

I've noticed something I don't like. The remove method which is passed a reference of an Object normally just removes the given object reference from the List. That's all. Then why do it with a Generic? The default Java Implementation does this and removing something from the list doesn't need a cast and makes code more "uncrashy". Just look at this (from my code):

public void onModifierFinished(IModifier pModifier, IEntity pItem) {
LevelSceneHandler.this.mCue.remove((BlockSprite)pItem);
LevelSceneHandler.this.mBlockSpritePool.recyclePoolItem((BlockSprite) pItem);
}

What if this code is called on an Entity that is no BlockSprite? It will cause an ClassCastException (afaik) instead of not doing anything (which is imo better in this case).

So why not change the remove method to remove(Object) in all collections?