473,387 Members | 1,535 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,387 software developers and data experts.

Interface-based programming

Hi group!

I've been reading Juval Lwys "Programming .NET Components", and I
think it is a very good book, giving nice guidelines on how to really
exhaust the possibilities of .NET in general.

Juval Lwy is indeed an advocate of using interface-based programming
(he wrote a chapter dedicated to it, and he's using it througout the
book).

I have one simple question. When designing your own components, is it
true - according to the rules of interface-based programming - that
you should create interfaces for your clients to use, and advertise
for them to do so? So every time I design a class, it should have a
corresponding interface?

Regards,
Patrick
Nov 16 '05 #1
5 3164
Hi Patrick,

By creating interfaces and publicizing it to your clients, you are promising
them that your component will have that definition, whatever the
implementation would be. Instead of making an abstract class public, it's
always better to hide the implementation and making ppl know only the
definitions.
HTH,
- Rakesh Rajan

"Patrick Kristiansen" <pa*****@sixulon.dk> wrote in message
news:45**************************@posting.google.c om...
Hi group!

I've been reading Juval Lwys "Programming .NET Components", and I
think it is a very good book, giving nice guidelines on how to really
exhaust the possibilities of .NET in general.

Juval Lwy is indeed an advocate of using interface-based programming
(he wrote a chapter dedicated to it, and he's using it througout the
book).

I have one simple question. When designing your own components, is it
true - according to the rules of interface-based programming - that
you should create interfaces for your clients to use, and advertise
for them to do so? So every time I design a class, it should have a
corresponding interface?

Regards,
Patrick

Nov 16 '05 #2
Patrick... I think the argument is to provide "an abstract skeletal
implementation class for each nontrial interface that you export" and to
use
interfaces "only to define types".

Regards,
Jeff
So every time I design a class, it should have a corresponding

interface?<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Patrick,

I am skeptical of any hard and fast rule that is offered as a "silver
bullet". A good design is often the intersection of multiple good ideas.

I have come to think of interfaces as useful when you have a bit of
functionality you want to expose as a type, *and* you can live with the
limitation that the implementation must be done at the point in the
hierarchy where the interface is inherited. Interfaces are especially
useful for standardizing specific behaviors across arbitrary classes that
don't share the same inheritance branch (IDisposable being a great example).

I always consider abstract classes and/or methods as an alternative to
interfaces. Sometimes I use one, sometimes the other.

I haven't read Juval's arguments so I won't comment beyond saying that if he
truly advocates an interface for every publicly-exposed class, he would have
an uphill battle convincing me. I suppose one could argue that if any class
can implement an interface, then a completely different class could be
substituted down the road for the underlying implementation, without
breaking client programs that use the interface. But I doubt how
universally useful this would actually be in practice.

--Bob

"Patrick Kristiansen" <pa*****@sixulon.dk> wrote in message
news:45**************************@posting.google.c om...
Hi group!

I've been reading Juval Lwys "Programming .NET Components", and I
think it is a very good book, giving nice guidelines on how to really
exhaust the possibilities of .NET in general.

Juval Lwy is indeed an advocate of using interface-based programming
(he wrote a chapter dedicated to it, and he's using it througout the
book).

I have one simple question. When designing your own components, is it
true - according to the rules of interface-based programming - that
you should create interfaces for your clients to use, and advertise
for them to do so? So every time I design a class, it should have a
corresponding interface?

Regards,
Patrick

Nov 16 '05 #4
Hi Patrick,

I agree that it's a pretty good book. I worked on a project that used
interfaces extensively and they solved a lot of problems in the context of
that application. So, I am an advocate of interfaces an encourage their
use. Some projects don't use interfaces, except for when they have to,
which I think is thier loss.

Joe
--
http://www.csharp-station.com

"Patrick Kristiansen" <pa*****@sixulon.dk> wrote in message
news:45**************************@posting.google.c om...
Hi group!

I've been reading Juval Lwys "Programming .NET Components", and I
think it is a very good book, giving nice guidelines on how to really
exhaust the possibilities of .NET in general.

Juval Lwy is indeed an advocate of using interface-based programming
(he wrote a chapter dedicated to it, and he's using it througout the
book).

I have one simple question. When designing your own components, is it
true - according to the rules of interface-based programming - that
you should create interfaces for your clients to use, and advertise
for them to do so? So every time I design a class, it should have a
corresponding interface?

Regards,
Patrick

Nov 16 '05 #5
Funny. After having read most of Juval's book, I constantly tumble
across things involving interfaces or I try to extend the use of
interface to real life. My brain is fried.

Today the tumble was across a blog entry that compares interfaces and
abstract classes to the Peter Sellers movie "Dr. Strangelove". I just
thought I wanted to post the link here.

http://blogs.msdn.com/FinServGuy/arc...25/234340.aspx

Regards,
Patrick

pa*****@sixulon.dk (Patrick Kristiansen) wrote in message news:<45**************************@posting.google. com>...
Hi group!

I've been reading Juval Lwys "Programming .NET Components", and I
think it is a very good book, giving nice guidelines on how to really
exhaust the possibilities of .NET in general.

Juval Lwy is indeed an advocate of using interface-based programming
(he wrote a chapter dedicated to it, and he's using it througout the
book).

I have one simple question. When designing your own components, is it
true - according to the rules of interface-based programming - that
you should create interfaces for your clients to use, and advertise
for them to do so? So every time I design a class, it should have a
corresponding interface?

Regards,
Patrick

Nov 16 '05 #6

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

Similar topics

4
by: Roy Pereira | last post by:
I have an application that is composed of a set of "Content" dlls and a viewer application. The viewer calls a standard set of functions that are present in all the dlls. I maintain this by...
3
by: Christof Warlich | last post by:
Hi, I'm looking for a more concise way than below to extend an existing interface. Just imagine that class Interface would have 1000 other members and class DerivedInterface only needs to add...
4
by: Doug | last post by:
I am working on an existing .NET (C Sharp) component that had a com interface that was used by a VB component. When it was originally written, it had the SSEAssemblyCom class below - minus the two...
6
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
20
by: Ole Hanson | last post by:
I am accessing my database through an interface, to allow future substitution of the physical datastore - hence I would like to declare in my Interface that my DAL-objects implementing the...
2
by: Alex Sedow | last post by:
Why interface-event-declaration does not support multiple declarators like event-declaration? Grammar from C# spec: variable-declarators: variable-declarator variable-declarators ","...
5
by: LS | last post by:
Can a WebMethod return an Interface type? Can we pass an interface parameter ? Example : public interface IEntity { long Id { get; set; } string Name { get; set; } }
12
by: masoud bayan | last post by:
I've come across something in Interface implementation that I am not sure is correct behavior in VB.NET (and maybe C#) or not? Consider following example: Public Interface IShape
15
by: Xah Lee | last post by:
On Java's Interface Xah Lee, 20050223 In Java the language, there's this a keyword “interface”. In a functional language, a function can be specified by its name and parameter specs....
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.