Solved

query on c#4 interfaces

Posted on 2012-03-20
3
339 Views
Last Modified: 2012-08-13
I have just been reading:
http://www.daniweb.com/software-development/csharp/threads/114364

At the bottom is the following:

Interface in object answer to one simple requirement facilitate mostly used functionality
you whant to give only what is use full to the user so using your object become simpler
if your class offer 40 functionality and one of your user commonly uses 3 of theme you dont whant to show him all of them it create noise. take an oo course.

Say for argument sake I did have a class with 40 functions on and only wanted to expose 3.

Is it the case that I need to create an interface that only has 3 function declarations and then create a new class which implements that interface or....?

Wouldn;t that mean ending up with a lot of sub version of the main class?

Excuse the stupid question still trying to get using interfaces straight in my head.

Thanks
0
Comment
Question by:scm0sml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 37742979
I don't know that I necessarily agree with using interfaces for the sole purpose of member hiding--though I suppose you could. An interface is really more like a contract. You are telling other code:  "Hey, I offer you these services and/or data." Using interfaces is also a way to get around .NET's single-inheritance behavior--you can inherit only one class, but you can implement n interfaces.

To answer your specific question, yes, you would create the interface that only has the 3 methods. This doesn't really hide anything, though. If I know the type of the object implementing the interface, then I can simply cast the object to that type and voila!, I have access to the public members again.
0
 

Author Comment

by:scm0sml
ID: 37743006
Right ok great thanks for that.
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37743011
some good articles:
http://www.4guysfromrolla.com/articles/110304-1.aspx

http://msdn.microsoft.com/en-us/library/ms229013.aspx

In terms of hiding code I would make the 3 public and the rest private . . . no need to create an interface for that.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question