Re: interface - why does implementation have to be public?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Patrick Steele [MVP] (patrick_at_mvps.org)
Date: 02/10/04


Date: Tue, 10 Feb 2004 15:33:10 -0500

In article <e$ul6pA8DHA.2796@TK2MSFTNGP09.phx.gbl>,
mfield@idonotlikespam.cce.umn.edu says...
> Below I've created an interface ... why do all implementations of the
> methods have to be public? What if I want them to be private or protected?
>
> public interface IOisWebPageStandard
> {
> void SomeMethod1();
> void SomeMethod2();
> void SomeMethod3();
> }

What's the point in having an interface (a "contract" between two
parties) if you don't want the other party to be able to see the method?
The goal of an interface is to define how the object can be accessed by
the outside world.

Private/protected stuff is an internal implementation detail to the
class and has no bearing on those that use the class.

-- 
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele


Relevant Pages

  • Re: Visitor pattern, code generation and additional sub classes
    ... this is a base class / interface. ...     void visitFoo; ... in all my visitor implementations ... ...
    (comp.object)
  • Re: replacing X Window System !
    ... just with some implementations. ... interface or most inter-application communication. ... Lack of application support (which requires backwards compatibility) is ...
    (Linux-Kernel)
  • Re: Cohens paper on byte order
    ... > interoperate with all other corect implementations, ... What I meant by this is that if implementations were to formally encode AES ... work with those that now exist since these all use an octet array interface. ... tidying up a small hole in the FIPS. ...
    (sci.crypt)
  • Re: Sencha Touch--Support 2 browsers in just 228K!
    ... particular context calls for, but each suited to a different context. ... implementations of interfaces do not even need to ... as it is the ideal packaging unit for many of those interface ... How do you define "framework" from a mechanical standpoint? ...
    (comp.lang.javascript)
  • Re: .NET DES CFB - useless interface?
    ... The problem is that the cryptography namespace provides an ICryptoTransform ... interface, ... the cipher mode code and padding code could have ... implementations, but as it is now, you have to re-code it with every managed ...
    (microsoft.public.dotnet.security)