473,406 Members | 2,352 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,406 software developers and data experts.

Why Implementation?

If there weren't a real strong reason for having it, Microsoft wouldn't have
bothered with including Implementation in the language. But doggone it, I'll be
darned if I can see what's so great about it. For starters, you've got to make
sure all the implemented members are present, whether you're going to use them
or not. That's cumbersome enough all by itself.

Why not just keep things nice and simple--build a class, and then instantiate it
and use its members? Much more--I rarely even use inheritance--seems like
spaghetti code to me.

But then again, my brain tends to get wrapped in a fog from time to time. If I'm
causing myself to miss out on something that'd improve my general approach, I'd
sure like to know about it.

So there's the question, I guess--Why Implementation?

TIA,
Jeff


Jul 21 '05 #1
11 1271
"Jeff Bowman" <wr*********@my.addess.com> wrote in
news:eB**************@TK2MSFTNGP12.phx.gbl:
For starters, you've got to make sure all the implemented members are
present, whether you're going to use them or not. That's cumbersome
enough all by itself.
Thats the contract.
instantiate it and use its members? Much more--I rarely even use
inheritance--seems like spaghetti code to me.


Ouch - inheritance is vital to any OO design.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
Jul 21 '05 #2
Jeff Bowman wrote:
If there weren't a real strong reason for having it, Microsoft wouldn't have
bothered with including Implementation in the language. But doggone it, I'll be
darned if I can see what's so great about it. For starters, you've got to make


I presume you are referring to Interface Implementation. Consider
Adobe Photoshop. It has a menu of available plugins that each
manipulate the image in some way. These plugins, however, are not
necessarily written by Adobe. They could be written by third parties.
When PS loads the plugin, it has no idea of how the plugin is
implemented. It only knows that the plugins support a particular set
of methods (read: interface).

For the plugin designer, he doesn't have to know anything about how
Adobe calls the methods. So long as he follows the contract, he knows
his plugin will work with PS.

Conside Microsoft's own ADO.Net. It provides an IDbConnection
interface. Various backends can be created that implement this
interface. For example the SQLConnection object implements the
interface. Oracle has a connection object that also implements this
interface.

The application designer only needs to code to the interface and in
doing so, the backend database can be changed without having to
recompile his code.

These are simple examples but I think that they help show the value of
interface programming.

Jul 21 '05 #3
Chad Z. Hower aka Kudzu <cp**@hower.org> wrote:
instantiate it and use its members? Much more--I rarely even use
inheritance--seems like spaghetti code to me.


Ouch - inheritance is vital to any OO design.


I disagree with that pretty strongly. I tend to aggregate rather than
using inheritance. It's useful occasionally, and where it *is* useful
it's absolutely invaluable. However, writing classes which should be
inherited from - especially outside your own assembly - requires a lot
more work to do it properly, and your implementation can end up being a
lot less flexible, as you need to stick to the same rules about which
method calls which other method etc.

There's a good article about this somewhere - I wish I could find it...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4
Jon Skeet [C# MVP] <sk***@pobox.com> wrote:
Ouch - inheritance is vital to any OO design.


I disagree with that pretty strongly. I tend to aggregate rather than
using inheritance. It's useful occasionally, and where it *is* useful
it's absolutely invaluable. However, writing classes which should be
inherited from - especially outside your own assembly - requires a lot
more work to do it properly, and your implementation can end up being a
lot less flexible, as you need to stick to the same rules about which
method calls which other method etc.


Just to clarify this somewhat - I'm talking about inheritance of
implementation here, not interface. Using interfaces is a different
matter, and something which is *very* handy when it comes to AOP, using
mock objects etc.

I just don't think that every OO design requires inheritance of
implementation.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #5
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in news:MPG.1d250fd1dbd282ff98c393
@msnews.microsoft.com:
I just don't think that every OO design requires inheritance of
implementation.


Neither do I - when I said "design" I meant as into C#, the CLS, etc. Imagine building the FCL without
inheritance, only interfaces. Oh wait we had that, it was called COM. :(
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
Jul 21 '05 #6
Chad Z. Hower aka Kudzu <cp**@hower.org> wrote:
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in news:MPG.1d250fd1dbd282ff98c393
@msnews.microsoft.com:
I just don't think that every OO design requires inheritance of
implementation.


Neither do I - when I said "design" I meant as into C#, the CLS, etc.
Imagine building the FCL without inheritance, only interfaces. Oh
wait we had that, it was called COM. :(


Oh, I see - certainly every OO language/platform has to have
inheritance, yes - and every large framework is *likely* to include
some inheritance.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #7
Chris Dunaway wrote:
I presume you are referring to Interface Implementation.
Yes. Pardon me for not clarifying.
Consider
Adobe Photoshop. It has a menu of available plugins that each
manipulate the image in some way. These plugins, however, are not
necessarily written by Adobe. They could be written by third parties.
When PS loads the plugin, it has no idea of how the plugin is
implemented. It only knows that the plugins support a particular set
of methods (read: interface).

For the plugin designer, he doesn't have to know anything about how
Adobe calls the methods. So long as he follows the contract, he knows
his plugin will work with PS.

OK, that makes sense... so far...
Conside Microsoft's own ADO.Net. It provides an IDbConnection
interface. Various backends can be created that implement this
interface. For example the SQLConnection object implements the
interface. Oracle has a connection object that also implements this
interface.
But--as I understand it--the actual functioning code exists in the members of
the implementing class and not the interface. Thus it seems the same as just
building a standalone class, but with additional complexity.
The application designer only needs to code to the interface and in
doing so, the backend database can be changed without having to
recompile his code.
Yes, I've heard that said before: "Code to interface, not implementation." But
again, if all the coding must be done in the down-level class, what's the point?
There doesn't seem to be any common code base, such as there can be with
inheritance.
These are simple examples but I think that they help show the value of
interface programming.


Please don't misunderstand my resistance--I WANT to know these things. I'm
rebutting only because I want to make sure the concept passes my personal tests.
I'm sure it will, and with flying colors, but at the same time I need full
comprehension.

Would you happen to know of some code I might look at wherein Interface
Implementation is NOT employed, and could be, and whose architecture thereby
suffers for it?

Thanks,
Jeff
Jul 21 '05 #8


Jeff Bowman wrote:
But--as I understand it--the actual functioning code exists in the members of
the implementing class and not the interface. Thus it seems the same as just
building a standalone class, but with additional complexity.
If you built a standalone class, the code that calls it will have to
reference that class and it then would not work with other classes,
even if they had the same method names, because they would be different
types.
Yes, I've heard that said before: "Code to interface, not implementation." But
again, if all the coding must be done in the down-level class, what's the point?
There doesn't seem to be any common code base, such as there can be with
inheritance.


I think inheritance implies that the derived classes can change or
extend the behavior of the base class. When implementing an interface
there is a contract which must be adhered to.

Jul 21 '05 #9
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
Oh, I see - certainly every OO language/platform has to have
inheritance, yes - and every large framework is *likely* to include
some inheritance.


Yes, exactly. :)
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Jul 21 '05 #10
OK, gotcha! That clears it up a lot, thanks. The next step, of course, is to
start fiddling around with it.

Maybe I should've done that before I opened my trap, think? ;-)

Chris Dunaway wrote:
Jeff Bowman wrote:
But--as I understand it--the actual functioning code exists in the members of
the implementing class and not the interface. Thus it seems the same as just
building a standalone class, but with additional complexity.


If you built a standalone class, the code that calls it will have to
reference that class and it then would not work with other classes,
even if they had the same method names, because they would be different
types.
Yes, I've heard that said before: "Code to interface, not implementation."
But again, if all the coding must be done in the down-level class, what's
the point? There doesn't seem to be any common code base, such as there can
be with inheritance.


I think inheritance implies that the derived classes can change or
extend the behavior of the base class. When implementing an interface
there is a contract which must be adhered to.

Jul 21 '05 #11
Funny, I googled for "interface+what's+the+point+c# and this thread came
up. Thanks for the great clarification. Let me see if I got the gist.

The creation of an interface is not so much to make your own life easier
as inheritance does in desigining a custom application. But it's more
for facilitating an outside customer or client who is using a library
you created.

It makes perfect sense now. Thanks again!

*** Sent via Developersdex http://www.developersdex.com ***
Jul 22 '05 #12

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

Similar topics

3
by: jenniferyiu | last post by:
IMHO, simply NO. False actually, practically.
9
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
29
by: Enrico `Trippo' Porreca | last post by:
Both K&R book and Steve Summit's tutorial define a getline() function correctly testing the return value of getchar() against EOF. I know that getchar() returns EOF or the character value cast to...
52
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low...
20
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this,...
7
by: desktop | last post by:
I the C++ standard page 472 it says that an associative container can be constructed like X(i,j,c) where i and j are input iterators to elements. But in the implementation there is no constructor...
6
by: Ralph | last post by:
Hi, I was reading effictive C++ and some other books again and they all tell you about hiding implementation details (proxy/pimpl/inheritance) but they never really explain when to use it. I...
0
by: anto.anish | last post by:
Hi , Since, i did not want to write instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of template...
1
by: anto.anish | last post by:
Hi , Since, i did not want to write explicit instantiations in Source file of all template methods for various different datatypes that my client might use, i choose to write implementation of...
173
by: Ron Ford | last post by:
I'm looking for a freeware c99 compiler for windows. I had intended to use MS's Visual C++ Express and use its C capability. In the past with my MS products, I've simply needed to make .c the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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
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...
0
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...

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.