473,604 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inteface (and life) sucks

I've never used Interface and never will.
But now I have to make major modifications to a large system where
almost all classes are based on some kind of Interface. Hundreds of
classes.
When I want do add a new property or method I have to modify the
interface and next I have to modify dozens of other classes or create
new inteface.
Sooner or later I will finish having a single class based on its own
interface. So what is the point of using Interface?

Madness.

MH
Nov 30 '05 #1
8 1203
loool Marius i understand your frastration,
Interfaces are used for two reasons
1. when you build a COM object you need the interfaces to be able to use the
code from other languages (ex vb6, c++, etc) that don't understant what the
hell a class is but the know interfaces.
2. if you build an interface for wrapping a database table, and add the
method save to it, then as many classes you have for the different tables in
your db, you only have to call Interface.Save( );
so insdead of knowing in your code, what sort of table class you have to use
you treat the object as an interface and get rid of the if and buts of the
code.
Also by building interfaces you have a more efficient view of your model, if
you don't use UML to model your project before start writting any code.
P.S. If you do a change in the interface just go to the classes the
impliment it and add the implement again :
public class SomeCLass (: MyInterface) <-- delete this part and write it
again, and will build a region with the properties and methods that you just
add
hope that help
"Marius Horak" <no****@eu.co n> wrote in message
news:eD******** ******@TK2MSFTN GP14.phx.gbl...
I've never used Interface and never will.
But now I have to make major modifications to a large system where
almost all classes are based on some kind of Interface. Hundreds of
classes.
When I want do add a new property or method I have to modify the
interface and next I have to modify dozens of other classes or create
new inteface.
Sooner or later I will finish having a single class based on its own
interface. So what is the point of using Interface?

Madness.

MH

Nov 30 '05 #2
Try :
http://msdn.microsoft.com/library/de...actClasses.asp

The "interface" just define the "contract" that the class should fullfill to
be usable (throught this interface). It doesn't deal at all with
implementation details.

In .NET for example the IComparable interface would allow compare a class
instance with another class instance. You can't provide a default
implementation as each class would implement its own specific comparison
criteria plus the functionaly exposed by this interface is totally a
different thing than the main goal of the class...

--
Patrice

"Marius Horak" <no****@eu.co n> a écrit dans le message de
news:eD******** ******@TK2MSFTN GP14.phx.gbl...
I've never used Interface and never will.
But now I have to make major modifications to a large system where
almost all classes are based on some kind of Interface. Hundreds of
classes.
When I want do add a new property or method I have to modify the
interface and next I have to modify dozens of other classes or create
new inteface.
Sooner or later I will finish having a single class based on its own
interface. So what is the point of using Interface?

Madness.

MH

Nov 30 '05 #3
Patrice wrote:
In .NET for example the IComparable interface would allow compare a
class instance with another class instance. You can't provide a
default implementation. ..


Yes, can, it wil return 0;
But my point is that when it comes to heavy modification of a large
system Interface (and to some extend abstarct classes) is pain in neck.
MH
Nov 30 '05 #4
Nassos wrote:
1. when you build a COM object you need the interfaces to be able to
use the code from other languages (ex vb6, c++, etc) that don't
understant what the hell a class is but the know interfaces.
I think you got point here.
2. if you build an interface for wrapping a database table, and add
the method save to it, then as many classes you have for the
different tables in your db, you only have to call Interface.Save( );


I think I can get the same without Interface.

Anyway, I will stick to my way of programming - NO F**Y INTERFACE.
I call it "coding for idiots", so any idiot can maintain my code.
Remember, 10% of costs is development, 90% maintenance.

Well, I feel better now.

We have another system, it's now Version 3.
Version 1 was ditched as it was to expensive to modify it.
Version 3 was written by a different team and is no better than Version
1 so our company decided to stick to Version 2.
All programmers involved in creating three versions were v.good coders
who were competing with each other who is a better DotNet programmers
(they wanted to impress bosses). Just the finish product is crap.
Funny thing, they don't work here any more.
MH
Nov 30 '05 #5
IMO would be bad as you wouldn't have a correct result if someone "forgot"
to implement the correct behavior.

A more convincing example could be ICommandDb that is provider dependant and
for which a default implementation would be very likely totally useless :
http://msdn.microsoft.com/library/de...classtopic.asp

Back to your own case, as soon as you code several times the same things in
multiple classes, then it's likelly that a class would be a better fit than
an interface....

--
Patrice

"Marius Horak" <no****@eu.co n> a écrit dans le message de
news:OI******** ******@TK2MSFTN GP09.phx.gbl...
Patrice wrote:
In .NET for example the IComparable interface would allow compare a
class instance with another class instance. You can't provide a
default implementation. ..


Yes, can, it wil return 0;
But my point is that when it comes to heavy modification of a large
system Interface (and to some extend abstarct classes) is pain in neck.
MH

Nov 30 '05 #6
Marius Horak <no****@eu.co n> wrote:
I've never used Interface and never will.
That sounds very unlikely to me. Never used IDisposable.Dis pose?
But now I have to make major modifications to a large system where
almost all classes are based on some kind of Interface. Hundreds of
classes.
Excellent. That's a good thing. It encourages loose coupling. You
needn't use interfaces within tightly coupled classes, but where the
coupling *should* be loose, using interfaces helps to keep that
looseness.
When I want do add a new property or method I have to modify the
interface and next I have to modify dozens of other classes or create
new inteface. Sooner or later I will finish having a single class based on its own
interface. So what is the point of using Interface?


1) It allows future implementations to be switched in and out without
any worries about implementation class hierarchy.

2) It makes it clear which parts of a class you are using - one class
may implement several interfaces sometimes, but you often only care
about one of them.

3) It makes unit testing really easy with mock frameworks like
EasyMock.NET - particularly if you're using inversion of control.

--
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
Dec 1 '05 #7
"Marius Horak" <no****@eu.co n> wrote in message
news:eD******** ******@TK2MSFTN GP14.phx.gbl...
The later maybe true (well, as far as *my* dealings with Microsoft go)
but the former is not.
I've never used Interface and never will.
You have missed a lot, then. There are a lot easier to understand if you
regard an interface as a behaviour. So the ICloneable interface means
that an object can be cloned, the ISerializable interface means that it
can be serialised. They say nothing about the implementation and so say
nothing about the class (type) but they say a lot about the what the
implementation does.

Consider this hyperthetical case:

interface IPrintable
{
void Render(PrinterC ontext ctx);
PaperType PerferredTypeOf Paper{get;}
event PrintedDelegate ItemPrinted;
}

Any class could implement this: Book, Photo, Page, Ticket. The point is
that if a class implements this interface it means it has the
respensibility to render itself to some printer context (say, a
container for a raster image), it has the responsibility to specify the
type of data it prefers to be printed on, and it can be notified that
the printing has completed. The class can do anything else it wants to
do, but it must do all of these things. The user of the interface is
only concerned with the interface's behaviour, it does not care about
anything else the object will do.

Imagine a printer object:

class Printer
{
public PrintItem(IPrin table doc);
}

This does not need to know about the type of the object passed, only
that it has the required behaviour. This gives you polymorphic code
because *any* object that implements IPrintable can be passed to
PrintItem. This is a *huge* advantage and your code will benefit
immensely from using interfaces.
But now I have to make major modifications to a large system where
almost all classes are based on some kind of Interface. Hundreds of
classes.
If the interfaces are factored correctly then this is great. IIRC the
maximum number of items in an interface is approximately five, if you
have more than that then you know that the interface was not correctly
factored and contains more than one behaviour.
When I want do add a new property or method I have to modify the
interface and next I have to modify dozens of other classes or create
new inteface.
Argh!!!!! NO NO NO!!!

This is not the way to do things. You should *only* add items to an
interface that are related to the behaviour. If the items represent
another behaviour then they should be in another interface (or possibly,
not in any at all). If the software you have is designed to have
interfaces with huge numbers of properties/methods then it is a poor
application and needs rewriting totally.
Sooner or later I will finish having a single class based on its own
interface. So what is the point of using Interface?

Madness.

If the application simply has an interface per class then there is no
point in using interfaces. The original developer should be made to
stand waist deep in sewage for soiling the good name of interfaces.

(Oh BTW, some of Microsoft's interfaces are designed very badly, and I
recommend the sewage treatment for those developers too.)

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Dec 1 '05 #8
Richard Grimes <ri******@mvps. org> wrote:

<snip>
Sooner or later I will finish having a single class based on its own
interface. So what is the point of using Interface?

Madness.


If the application simply has an interface per class then there is no
point in using interfaces. The original developer should be made to
stand waist deep in sewage for soiling the good name of interfaces.


Ever done unit testing with mock objects? Much easier with interfaces.

Anyway, even if there's only one implementation *now*, that doesn't
mean it's not a good idea to design cleanly for the future.

--
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
Dec 1 '05 #9

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

Similar topics

13
1733
by: nospam | last post by:
DEAR MICROSOFT: WOULD YOU PLEASE put up a web page showing the price list of EXPECTED COSTS for MOM & POP when choosing between MySql/PHP and .NET. FIRST: Show INITIAL COSTS for like a 5-10 page web site that can take a few orders... INCLUDE THE ISP charges..developer, software...
13
3299
by: BigDaDDY | last post by:
Um yeah....In case you haven't figured it out, Microsoft sucks. I'm going to be kicked back in my chair eating popcorn and watching football 10 years from now, while all you clowns are scrambling to rewrite all your code because Microsoft upgraded all their crap and nothing you wrote 10 years earlier works. It doesn't take a rocket scientist to figure out that Microsoft is unreliable. Try opening an Excel 95 spreadsheet you wrote in...
3
9508
by: gemel | last post by:
Interface definitions do no not contain implementation, only signtures. That is there real purpose. Here thow we have an Inteface which does not have any implementation code but it has to be included in the creation of a Web User Control. Please tell me how it actually does something? Regards John L
1
1457
by: Matthias Langbein | last post by:
Hi all, how do I solve this problem: Interface A {...} Class B : System.Windows.Forms.UserControl, A {...} ClassC : System.Windows.Forms.UserControl, A
3
1574
by: devgupta01 | last post by:
How to see methods of class/inteface of library if i m using console. Please give an example. thnx
0
7997
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
8419
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
8409
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...
0
8280
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...
0
6739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3955
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2434
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
1
1526
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1266
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.