Solved

query on c#4 interfaces

Posted on 2012-03-20
3
301 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
3 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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
Comment Utility
Right ok great thanks for that.
0
 
LVL 39

Expert Comment

by:Kyle Abrahams
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now