Got a reference for that? I've heard "prefer composition over inheritance" (GoF) but never have I heard that classes should never be subclassed.
Got a reference for that? I've heard "prefer composition over inheritance" (GoF) but never have I heard that classes should never be subclassed.
I wouldn't go so far to say "never subclass", but I'd say most of the time, you won't need to subclass.
>I wouldn't go so far to say "never subclass", but I'd say most of the time, you won't need to subclass.
Yeah, I would agree with that. A lot of OOP mechanisms like inheritance, or design patterns, get overused a lot. I'm not saying it's what you were doing, but I've seen it mostly in code written by newish programmers. It seems that once the concepts of OOP click in their mind, they get excited and eager to put them to work, so they use them where they're not really appropriate. I was definitely guilty of that, way back in the day. But once the novelty wore off, and I realized that I was just creating over-architected messes, I quit doing it.
It helps you realize that programming is simply about data, and how you manipulate it.
Design patterns, OOP, conventions, etc are all just secondary tools that sometimes help you do that.
Well, whatever they said, they started off with "OOP theory essentially says that..."
So, if it's OO theory, I'd appreciate if someone could provide me a reference that shows that it's OO theory, and not just someone's personal opinion.