Re: Programming to an Interface




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

.



Relevant Pages

  • Re: TextOut() to a DialogBox ???
    ... code size as if it had meaning, ... meaningless as a metric of reuse, productivity, or ... Minimizing the public interface might be a good metric. ... In programming, you can code for size or speed. ...
    (microsoft.public.vc.mfc)
  • Re: home made home security
    ... to interface to the RS485 master circuit. ... You do understand that the "master circuit" in this case needs to be a PC, ... What is the value of your time spent programming that you would ... Home security automation systems _don't_ cost thousands of dollars if you ...
    (comp.home.automation)
  • Re: TextOut() to a DialogBox ???
    ... code size as if it had meaning, ... meaningless as a metric of reuse, productivity, or ... Minimizing the public interface might be a good metric. ... In programming, you can code for size or speed. ...
    (microsoft.public.vc.mfc)
  • Re: how to refernce a folder?
    ... sometimes the best thing to do is attempt to follow the advice and see what happens. ... All advice, strategies, design patterns, etc. in programming are intended to make things _easier_. ... The interface should be general purpose. ... In programming generally, not just OOP, not just MVC, MVP, etc. it is useful to keep in mind the different between API or "interface" and implementation. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: TextOut() to a DialogBox ???
    ... He actually said code size meaning source code size, ... In programming, you can code for size or speed. ... process to review ONLY the "interface" files (in the true ... Part of the role of a good compiler is to peek across ...
    (microsoft.public.vc.mfc)