473,748 Members | 10,771 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interfaces & C#...

I have a set of developers who have gone off and implemented an interface
for nearly all classes in a project\solutio n, now some of these classes will
need interfaces as they implement the provider design pattern and other
classes are exposed to the outside world, but the majority are internal
classes and therefore IMO they don't require an interface.

I can find plenty of articles on how to implement interfaces but I can't
find any explaining why the over use of interfaces is bad
(design\practic e) - does anyone know of such articles\links?

Cheers

Dave
Jul 26 '06 #1
8 1575
The fact that the classes are hidden from the outside world does not
mean that interfaces are not needed. Take the following as an example
....

You have to implement several data access code implementations that
will only be used by your application, thus there is not need to expose
them. You have to create an interface in order to have a single point
of communication and interface contract across all of your
implementations .

Over-use of anything in general is considered a bad practice, but are
you sure that in the particular case it's a bad design ?

Regards,
Tasos

Dave wrote:
I have a set of developers who have gone off and implemented an interface
for nearly all classes in a project\solutio n, now some of these classes will
need interfaces as they implement the provider design pattern and other
classes are exposed to the outside world, but the majority are internal
classes and therefore IMO they don't require an interface.

I can find plenty of articles on how to implement interfaces but I can't
find any explaining why the over use of interfaces is bad
(design\practic e) - does anyone know of such articles\links?

Cheers

Dave
Jul 26 '06 #2
In your example if I understand you correctly you offer the scenario of data
access pattern where I might have several implementation of data access so
that I can support multiple data stores (MS-Sql, Oracle etc).
IMO the logical conlcusion of this would be to encapsulate a single
implementation into it own's assembly implementing a publicly exposed
interface so that maintainence issues for that single implementation do not
affect the other implementations (like the would if they were all grouped
into a single assembly).

Am I missing your point?

Your point about over use is valid IMO and this is where I am coming from
some of the developers have implemented interfaces for every class\struct...

Cheers

Dave
"Tasos Vogiatzoglou" <tv*****@gmail. comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
The fact that the classes are hidden from the outside world does not
mean that interfaces are not needed. Take the following as an example
...

You have to implement several data access code implementations that
will only be used by your application, thus there is not need to expose
them. You have to create an interface in order to have a single point
of communication and interface contract across all of your
implementations .

Over-use of anything in general is considered a bad practice, but are
you sure that in the particular case it's a bad design ?

Regards,
Tasos

Dave wrote:
>I have a set of developers who have gone off and implemented an interface
for nearly all classes in a project\solutio n, now some of these classes
will
need interfaces as they implement the provider design pattern and other
classes are exposed to the outside world, but the majority are internal
classes and therefore IMO they don't require an interface.

I can find plenty of articles on how to implement interfaces but I can't
find any explaining why the over use of interfaces is bad
(design\practi ce) - does anyone know of such articles\links?

Cheers

Dave

Jul 26 '06 #3
Dave,

of course your point is valid, I just wanted to raise a point about the
"private interface" issue. I believe that an interface for
private/internal classes in not a bad thing per se, but only in the
context of over/mis-use.

About your situation now. It's a rather "philosophi cal" issue whether
the design of your x-colleagues is wrong. I personally hate
over-anything (overuse, overdesign etc) ... but you will have a hard
time raising an issue about the design (of course, if they are willing
to hear it should be easier :) ).

Regards,
Tasos

Dave wrote:
In your example if I understand you correctly you offer the scenario of data
access pattern where I might have several implementation of data access so
that I can support multiple data stores (MS-Sql, Oracle etc).
IMO the logical conlcusion of this would be to encapsulate a single
implementation into it own's assembly implementing a publicly exposed
interface so that maintainence issues for that single implementation do not
affect the other implementations (like the would if they were all grouped
into a single assembly).

Am I missing your point?

Your point about over use is valid IMO and this is where I am coming from
some of the developers have implemented interfaces for every class\struct...

Cheers

Dave
"Tasos Vogiatzoglou" <tv*****@gmail. comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
The fact that the classes are hidden from the outside world does not
mean that interfaces are not needed. Take the following as an example
...

You have to implement several data access code implementations that
will only be used by your application, thus there is not need to expose
them. You have to create an interface in order to have a single point
of communication and interface contract across all of your
implementations .

Over-use of anything in general is considered a bad practice, but are
you sure that in the particular case it's a bad design ?

Regards,
Tasos

Dave wrote:
I have a set of developers who have gone off and implemented an interface
for nearly all classes in a project\solutio n, now some of these classes
will
need interfaces as they implement the provider design pattern and other
classes are exposed to the outside world, but the majority are internal
classes and therefore IMO they don't require an interface.

I can find plenty of articles on how to implement interfaces but I can't
find any explaining why the over use of interfaces is bad
(design\practic e) - does anyone know of such articles\links?

Cheers

Dave
Jul 26 '06 #4
You have hit the nail on the head :)

I am now responbilie for the overall design and getting the team to a
standard...
"Tasos Vogiatzoglou" <tv*****@gmail. comwrote in message
news:11******** *************@p 79g2000cwp.goog legroups.com...
Dave,

of course your point is valid, I just wanted to raise a point about the
"private interface" issue. I believe that an interface for
private/internal classes in not a bad thing per se, but only in the
context of over/mis-use.

About your situation now. It's a rather "philosophi cal" issue whether
the design of your x-colleagues is wrong. I personally hate
over-anything (overuse, overdesign etc) ... but you will have a hard
time raising an issue about the design (of course, if they are willing
to hear it should be easier :) ).

Regards,
Tasos

Dave wrote:
>In your example if I understand you correctly you offer the scenario of
data
access pattern where I might have several implementation of data access
so
that I can support multiple data stores (MS-Sql, Oracle etc).
IMO the logical conlcusion of this would be to encapsulate a single
implementati on into it own's assembly implementing a publicly exposed
interface so that maintainence issues for that single implementation do
not
affect the other implementations (like the would if they were all grouped
into a single assembly).

Am I missing your point?

Your point about over use is valid IMO and this is where I am coming from
some of the developers have implemented interfaces for every
class\struct.. .

Cheers

Dave
"Tasos Vogiatzoglou" <tv*****@gmail. comwrote in message
news:11******* *************** @h48g2000cwc.go oglegroups.com. ..
The fact that the classes are hidden from the outside world does not
mean that interfaces are not needed. Take the following as an example
...

You have to implement several data access code implementations that
will only be used by your application, thus there is not need to expose
them. You have to create an interface in order to have a single point
of communication and interface contract across all of your
implementations .

Over-use of anything in general is considered a bad practice, but are
you sure that in the particular case it's a bad design ?

Regards,
Tasos

Dave wrote:
I have a set of developers who have gone off and implemented an
interface
for nearly all classes in a project\solutio n, now some of these
classes
will
need interfaces as they implement the provider design pattern and
other
classes are exposed to the outside world, but the majority are
internal
classes and therefore IMO they don't require an interface.

I can find plenty of articles on how to implement interfaces but I
can't
find any explaining why the over use of interfaces is bad
(design\practi ce) - does anyone know of such articles\links?

Cheers

Dave

Jul 26 '06 #5
Dave,

The Framework Design Guidelines book contains information about
overusing interface. Since the overuse is mostly contained within a
single assembly the problem isn't that bad. Had those interfaces been
a part of the public interface it could have been worse.

A lot of developers fail to realize that intefaces are difficult to
version The book claims that they're more difficult to version than an
abstract class. I happen to agree. The reason is because they're not
extendable. Remember, adding something to an interface is a breaking
change. Contrast that with a class where it is possible to add
properties and methods without causing a breaking change.

The book lists several important considerations and guidelines when
using interfaces among other things. It even points problems with the
base class library caused by interfaces. I think it should be required
reading for all .NET developers.

Brian

Dave wrote:
I have a set of developers who have gone off and implemented an interface
for nearly all classes in a project\solutio n, now some of these classes will
need interfaces as they implement the provider design pattern and other
classes are exposed to the outside world, but the majority are internal
classes and therefore IMO they don't require an interface.

I can find plenty of articles on how to implement interfaces but I can't
find any explaining why the over use of interfaces is bad
(design\practic e) - does anyone know of such articles\links?

Cheers

Dave
Jul 26 '06 #6
"Dave" <da**@nospamnoe mial.comwrote in message
news:eK******** ******@TK2MSFTN GP06.phx.gbl...
>I have a set of developers who have gone off and implemented an interface
for nearly all classes in a project\solutio n, now some of these classes
will need interfaces as they implement the provider design pattern and
other classes are exposed to the outside world, but the majority are
internal classes and therefore IMO they don't require an interface.
Sounds like they think they are trying to future-proof these internal
classes, so that at some point they can be replaced with other
implementations . But that's a false economy, for the reasons others have
noted.

Work should not not be done that doesn't solve a current problem. There are
simply too many current problems to spend time trying to predict which ones
will arise in the future.

///ark
Jul 26 '06 #7
Mark Wilden <Ma********@new sgroups.nospamw rote:
"Dave" <da**@nospamnoe mial.comwrote in message
news:eK******** ******@TK2MSFTN GP06.phx.gbl...
I have a set of developers who have gone off and implemented an interface
for nearly all classes in a project\solutio n, now some of these classes
will need interfaces as they implement the provider design pattern and
other classes are exposed to the outside world, but the majority are
internal classes and therefore IMO they don't require an interface.

Sounds like they think they are trying to future-proof these internal
classes, so that at some point they can be replaced with other
implementations . But that's a false economy, for the reasons others have
noted.

Work should not not be done that doesn't solve a current problem. There are
simply too many current problems to spend time trying to predict which ones
will arise in the future.
There are other uses for interfaces, however - most notably (from my
point of view) for testing, particularly with mocking frameworks. Using
inversion of control to inject interface-based collaborators can make
it *much* easier to unit test classes.

(I agree with all the versioning difficulties, etc though.)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 26 '06 #8
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************** *@msnews.micros oft.com...
>
There are other uses for interfaces, however - most notably (from my
point of view) for testing, particularly with mocking frameworks. Using
inversion of control to inject interface-based collaborators can make
it *much* easier to unit test classes.
Yes, absolutely. I just went through a big mockerama where I had to create
interfaces for many of the classes in a legacy project. However, I'd call
interfaces like that solutions to a present problem.
Jul 26 '06 #9

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

Similar topics

8
3219
by: Shawn Casey | last post by:
Consider the following code: interface IBase { virtual void BaseFunction() = 0; }; interface IDerived : public IBase { virtual void DerivedFunction() = 0;
1
2208
by: baylor | last post by:
In C#, an interface cannot mark any method as static. i'm told the ILASM supports it but i've never tested that Two questions. First, why? OK, i've heard the reason about interfaces being allocated on the stack but that's not a real reason. Which is OK because this isn't a real question, it's just a complaint dressed up to look like a reason Second question. If a language doesn't support a fairly obvious feature, one has to wonder if...
30
2510
by: Frank Rizzo | last post by:
We are having one of those religious debates at work: Interfaces vs Classes. My take is that Classes give you more flexibility. You can enforce a contract on the descendant classes by marking methods abstract (which is all that an interface does). In addition, the classes allow you to be flexible by adding functionality that child classes inherit. Or by providing optional functionality via virtual methods. Now, I understand that...
8
1783
by: John | last post by:
What is the purpose / benefit of using an interface statement? It doesn't seem like anything more than a different way to make a class... (except you can't define any procedures in an interface like you can do in a class). I'm obviously missing something... John
18
1985
by: _dee | last post by:
Question about best use of interfaces: Say there's a 'Master' class that needs to implement a few interfaces: class Master : I1, I2, I3 { } The actual code already exists in smaller classes that each
10
2097
by: Betina Andersen | last post by:
I have inherited a VB.NET dll that I am using from common asp. My problem is to get the messages from the dll to the Ie client, I can see the messages in the Eventlog on the IIS server so I know they are there, but how do I get them to show in IE? The original code was: MsgBox("Kunne ikke finde databasenavn udfra den angivne DSN: " & DSN) I tried to change that to: Result = MessageBox.Show("Kunne ikke finde databasenavn udfra den...
7
2954
by: hufaunder | last post by:
I have an interface for which I want to define a particular constructor. I want to force the user to implement this particular constructor. Even better would be if I could make sure there is no default constructor. That might be a bit messy because the implementer of the interface should have the freedom to add any function/constructor he wants on top of the interface. But can't I at least force that one particular constructor must be...
10
3355
by: hufaunder | last post by:
I have an interface where I would like to have some static functions. When I add "static" to any of the interface functions I get the following error: "The modifier 'static' is not valid for this item". Why is it not possible to define static functions in an interface? Thanks
22
2109
by: RSH | last post by:
Hi, I have been reading on interfaces working on samples I've run across on the web. For the life of me I cannot seem to grasp them. It appears to me that interfaces are simply blueprints to a class, that when implemented, they require the implementing calss to make sure that each of the properties, functions etc. are handled by the class. (????) What I am really having a problem with is how they overcome the limitation
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.