Re: Programming to an Interface
- From: "Ed" <iamfractal@xxxxxxxxxxx>
- Date: 13 May 2006 06:57:36 -0700
GoogleEyeJoe wrote:
However, I am still don't think I've yet
found a reason why from programming to interfaces is better than
programming to implementation, with the exception of polymorphic
behaivour. It appears to me that programming to interfaces suffer from
the same downfalls as programming to an object's exposed methods...
Regards,
Craig.
"What does confuse me however, is the
notion that programming to an interface reduces the likelihood that
changing an object's implementation will break existing code (code
created by the client of the object (that implements the interface)."
You seem to be looking for two benefits of programming to an interface:
1) Polymorphism.
2) Improved likelihood of not impacting clients' code.
But these aren't two separate benefits; the second is a mere
consequence of the first.
There is no sense in which programming to an interface reduces the
likelihood of impacting clients' code except within the context of
polymorphism.
In other words, you seem to appreciate the benefit of programming to an
interface in terms of polymorphism, and are looking for some other
benefit not related to polymorphism; but there isn't any: programming
to an interface is just a mechanism which allows polymorphism to
operate. If you're not using polymorphism, then you don't need
interfaces.
(Note I use the word, "Interface," here in the Java sense; of course
the non-private methods and data of a class is also its interface, but
that's not the meaning discussed here.)
..ed
--
www.EdmundKirwan.com - Home of The Fractal Class Composition
.
- References:
- Programming to an Interface
- From: GoogleEyeJoe
- Re: Programming to an Interface
- From: Patrick May
- Re: Programming to an Interface
- From: GoogleEyeJoe
- Programming to an Interface
- Prev by Date: Re: Programming to an Interface
- Next by Date: Re: Searching OO Associations with RDBMS Persistence Models
- Previous by thread: Re: Programming to an Interface
- Next by thread: Re: Programming to an Interface
- Index(es):
Relevant Pages
|