While reviewing some code recently, I came across a superclass that defined an instance variable but the subclasses used that variable for completely different things. One subclass used the variable to hold a stream and sent stream messages to it while another used it to hold a drawing context and sent drawing messages to it. The superclass didn't reference the variable at all. Any methods that would have referred to the variable were left for the subclasses to implement. This means that the variable isn't really the same variable at all. I'd rather move the variable down into the subclasses and call the variables more specific names. There's no value in making it an instance variable in the superclass if you can't share any methods that reference that variable.
Download