473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Interfaces, Big Deal!!

Hi,

Please help me to understand this, because I don't see what I'm missing.

I was reading a lot of examples on Internet that explain that C# doesn't
implement multiple inheritance it implement multiple interfaces.

So, I keep reading and reading and reading to see how can I resolve my
problem with interfaces.

The conclusion is I'm writing to all of you because I couldn't find the way
to resolve my problem.

If I can create multiples interfaces and I have to implement the methods on
the derived class, then what's the big deal.

I know if I declare a class that inherit from one interface is useful
because for example

I can create an Interface called Shape, and 3 Classes called Circle,
Rectangle, and Line.

If on my interface I declare my method Draw(); and I implement on each
derived class then I could do the next.

IShape s = (IShape) AnyShapeObject;

s.draw();

I think is very useful and I used many times. But now the question is what
is the similitude between Multiple Inheritance and Multiple Interfaces???? I
don't see too much

Why on Internet always speak for Multiple Inheritance and Multiple
Interfaces like they have a relation???

My Case:

I have many Windows Control and I'm inherit each one for create my own
Controls.

For example I want to add method called getVirtualSize();

I create and interface

IVirtualSize

It contain

public getVirtualSize();

So, on my derived class I MUST implement my method getVirtualSize and that's
it.

Very nice!!!

Now the real question is, I create a lot of logic on my paint method; this
logic is exactly the same for all derived classes, why do I have to
implement this entire logic on each Control???

With multiple inheritances you just create a class
ExtendedControlFuncionality and Implement a method OnPaintEx, and really I
have a nice source code, because my class ExtendedControlFuncionality has
all the new extended functionality.

Then how can I do the same with interfaces????

I don't want to put my piece of code on every derived class, it is a mess
and very difficult to maintain, I want to centralize my source code and in
the same time I want to use many methods of the base classes, that means I
want to use all the protected methods that the controls offer to me because
OnPaintEx needs those.

Really, here is only one example, the reality is that is a lot of source
code that I "should" implement on every Control, I don't want to do that.

Thanks, the answers will be really appreciated.

Gustavo.


Nov 15 '05 #1
0 800

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Franco Gustavo | last post by:
Hi, Please help me to understand this, because I don't see what I'm missing. I was reading a lot of examples on Internet that explain that C# doesn't implement multiple inheritance it...
7
by: Ant | last post by:
Hi, I’m wondering what practical use is there for creating interfaces. I can fully appreciate creating an abstract class for the purpose of inheriting, but why an interface? Is it just to...
27
by: jm | last post by:
I am having trouble understanding the purposes of an interface, even though the concept of interfaces is around me all the time (user interface, for example). I'm just not understanding software...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.