3 ms·
(Edited original post to clarify that I was not talking about performance.) If the inheritance already exists and make sense, adding another overridden method
by skybrian 14y ago
(Edited original post to clarify that I was not talking about performance.)
If the inheritance already exists and make sense, adding another overridden method may be a win. The thing I'm arguing against is introducing a new class hierarchy to remove an if statement. Inheritance is a big gun and you shouldn't use it unless it significantly cleans up the code.
In this particular case, extending User to get TwitterUser is a particularly bad example because it's adding an is-a relationship when has-a is better. After all, users may have both twitter accounts and email addresses, and these can change dynamically (they can edit their notification settings). Unthinking use of inheritance is far worse than extra if statements.