Re: Evangelizing
Jim Cooper writes:
Quote
>You can let different clients access different interfaces to the same
>object
Only if you rely on coding convention. There is nothing to stop every
client from using every interface.
How do you use an interface on a given object implementing that interface if
you don't have the source code for the class of the object, nor the
declaration of the interface itself?
Unless your name is Danny Thorpe or Hallvard Vassbotn, I doubt you are able
to do it. No offense! ;-)
Quote
Are you after something like the Eiffel
approach others have been talking about?
Something in that direction, but probably at a more abstract level.
Quote
And one of the two biggest problems I see with interface-based code
is having too many interfaces on one object.
If the object has multiple responsibilites (able to play different roles),
that isn't a problem IMO. that is a situation when interfaces shine.
With interfaces, you can get away with being less "strict" in
implementing/constructing your classes, you can use quite a lot of tricks in
the implementation, without that complexity "leaking out".
Quote
>some clients may see some "secret" features that other clients do
>not know the existence of.
Seems to me that you should not be using just the one object, then.
If the responsibilities naturally belongs to the same object, or it simply
is convenient to implement it that way, interfaces let you get away with
having a bit more "dirty" classes.
Quote
>(You don't need to have public methods in order to implement an
>interface.)
All methods defined in an interface are by definition public.
>When using interfaces, classes are implementation details.
Code in methods in classes is always implementation detail whether or
not an interface is involved.
I'm not only considering the implementation of methods here, I am considering
the whole class (methods, fields, the class' place in the class hierarchy)
as being only "locally" interesting when using interfaces.
Quote
You've used this expression several
times now, but I don't see what you're getting at - you seem to have used
it in at
least 2 different contexts.
It is the features/responsibilites/roles which are important, how you
combine those into classes is "implementation".
The MFC pattern doesn't dictate you to implement it with three classes, it
is the three roles which are the essence of the pattern.
Cheers,
Jarle