Another classic on Interfaces

What good is an interface if you implement it correctly, but …

instead of spelling out like

class MyH4X0rClass implements MyC00lInterface {
void interfaceMethod(){ ....

it looks more like this?

class MyStupidClass { /*forgets to implement MyC00lInterface*/
void interfaceMethod(){ ....

Next thing you know you are testing

if(f00 instanceof MyC00lInterface) .....

and nothing happens – ever. It took me about half a day of work to get that one caught.

And: No I didn’t read t00 much M3g4T0ky0, there is no such thing as t00 much …. it’s all Daniel‘s fault anyway.

So to avoid this. Never use an if without an else. You knew that already? Seems I didn’t :-/

By Yashima

Writer of code and stories

1 comment

  1. Pingback:

Comments are closed.