Interface vs Public class member ??

G

Guest

Dear all,

I have one question base on a choice of having a public interfcace access
compare to public class member.

IN other word let say that I have a public interface named ImyInterface with
public function and property.

Then I define a class which implements that interface.My class contains
public fcunction which provide services.

What would be advaantage and drawback of accessing my class service directly
throught public function or by public Interface member ( in that case I
declare all member of my class as private and the only access will be through
that interface)

thnaks for comments
regards
serge
 
K

Kevin Spencer

An Interface is like a contract, which establishes a minimum set of
properties and methods that a class implementing that interface must
implement. It is useful for situations in which a variety of classes are
expected to be created, but where the client using those classes will not
know their types. As long as the client knows the Interface, it can interact
with any class that implements that Interface.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
G

Guest

is it a good idea to acces my class member through public interface memeber
only and declare my class memeber as all private ?
 
K

Kevin Spencer

Not necessarily.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top