Is type checking ever OK?
问题 Is type checking considered bad practice even if you are checking against an interface? I understand that you should always program to an interface and not an implementation - is this what it means? For example, in PHP, is the following OK? if($class instanceof AnInterface) { // Do some code } Or is there a better way of altering the behaviour of code based on a class type? Edit : Just to be clear I am talking about checking whether a class implements an interface not just that it is an