473,396 Members | 1,815 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.

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 1193
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.con> wrote in message
news:eD**************@TK2MSFTNGP14.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.con> a écrit dans le message de
news:eD**************@TK2MSFTNGP14.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.con> a écrit dans le message de
news:OI**************@TK2MSFTNGP09.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.con> wrote:
I've never used Interface and never will.
That sounds very unlikely to me. Never used IDisposable.Dispose?
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.com>
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.con> wrote in message
news:eD**************@TK2MSFTNGP14.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(PrinterContext ctx);
PaperType PerferredTypeOfPaper{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(IPrintable 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.com>
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
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...
13
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...
3
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...
1
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
0
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,...
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
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.