Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

query on c#4 interfaces

Posted on 2012-03-20
3
Medium Priority
?
365 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

730 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