raylopez99 said:
Personally, I don't like inheritance, unless you need runtime
polymorphism using a base class reference. I don't like even single
inheritance, as it seems to be less flexible than a composition or
nested class. Everything is "HAS-A" but few things are "IS-A" it
seems to me.
Yikes! Inheritance is the cat's meow!
I create both concrete as well
as abstract base classes all the time. I mean like all the time. I
constantly run up against the pattern where you start designing a class
and realize that there will be multiple "flavors" of the class. It's
base class time. I guess I like them so much mostly because (1) I
absolutely detest writing the same line of code more than once (and
inheritance is one major way that allows me to do that) and (2) it's one
of the basic principles of OO development. And the polymorphism you
mention is an awesome "side" benefit.
Now I could understand you saying that you aren't big on some of the key
OO concepts. That's a perfectly legitimate attitude to have, IMO, and I
could understand that opinion.
This isn't to say I don't use nested classes--well, other classes as
fields within a class--all the time. I do. Maybe once in a blue moon do
I find a reason for a nested class; they don't have much of a use to me
since I pretty much always want to be able to reuse a class I've created
and if today it seems to make sense to be nested into another class.
Whenever I've done that I've more often than noted "backed out" the
nested class so that other classes have access to it just like the
containing class did.
BTW an excellent book--that I'm slowly working through--is this book
on class construction: "Design Patterns" by Gamma et al. (forward by
Grady Booch) (1977, 1995). You learn about cool classes like the
"Singleton", which by now is pretty well known, and other such
constructs.
Yes, the Gang of Four should be read by any person wanting to do OO. The
cool lingo that all the kids use for things like a singleton these days
are "patterns," don't-cha know?