By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Interface vs Public class member ??

P: n/a
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
Apr 25 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"calderara" <ca*******@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
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

Apr 25 '07 #2

P: n/a
is it a good idea to acces my class member through public interface memeber
only and declare my class memeber as all private ?
"Kevin Spencer" wrote:
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

"calderara" <ca*******@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
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


Apr 25 '07 #3

P: n/a
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

"calderara" <ca*******@discussions.microsoft.comwrote in message
news:16**********************************@microsof t.com...
is it a good idea to acces my class member through public interface
memeber
only and declare my class memeber as all private ?
"Kevin Spencer" wrote:
>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

"calderara" <ca*******@discussions.microsoft.comwrote in message
news:41**********************************@microso ft.com...
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



Apr 26 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.