Since the documentation states that the command registered last should be the one used, we propose a different implementation which in our Java port currently looks like this:
public void registerCommand( String notificationName, Class commandClassRef )
{
if (null != this.commandMap.put( notificationName, commandClassRef )) return;
this.view.registerObserver( notificationName, new Observer( new IFunction()
{
public void onNotification( INotification notification )
{
executeCommand( notification );
}
}, this ) );
}
We replace the command if one was registered before, but do not add another observer. Okay with you?