Thank you Jeff. I am digesting this. It's a big meal. As my Dad used to say,
my eyes are bigger than my stomach.
Just a bit of qualification of what you mean by;
1 Avoid extending a class unless it was designed to be extended?
a) what's one bad idea that would make it a bad idea with an eye toward
extending.
b) one good idea with an eye toward extension.
and
2. Use a base class if you need to include implementation detail
a) you mean implementation details get fleshed out in the derived classes?
Or are you saying certain implementation details should be in the base class
as opposed to somewhere else?
I really appreciate the your responses. Fortunately I wasn't the architect
on a recent project but I found out you can be thrown into a lego pond and
still expect to hook a few things up. -hazz
"Jeff Louie" <jeff_louie@yahoo.com> wrote in message
news:%23mwh5fiDFHA.1408@TK2MSFTNGP10.phx.gbl...[color=blue]
> 1)Favor containment.
> 2)Avoid extending a class unless it was designed to be extended.
> 3)If you have a well defined contract that will be implemented by many
> classes use an interface. An interface represents a purely abstract IS_A
> relationship.
> 4)If the contract is evolving, consider using a base class so that you
> can provide default implementations of any new methods so that clients
> that use your base class can be recompiled without breaking.
> 5)Use a base class if you need to include implementation details.
>
> That said... every time I try to solve a problem I seem to start by
> describing the contract with an interface say IVersionable. Then I end
> up writing an abstract class with default implementations as in
> AbstractVersion. Then I end up creating concrete classes based on the
> Abstract class as in Version : AbstractVersion.
>
> So I would try this pattern: Interface -- AbstractInterface -- Class
> which uses both interfaces and base classes and offers both options to
> the user of the "interface/class."
>
> Regards,
> Jeff
>
> *** Sent via Developersdex
http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]