× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Buck,

Sorry for the delay in responding. I've been knee-deep in an upgrade over
the last few days, and I thought someone else would have picked up the ball
by now.

> So "interface" is really a way round the single inheritance restriction?
We
> can define "utility" classes that aren't really a subclass of anything
else.
> Without "interface" we'd be locked in to creating artificial objects to
> contain utility classes.
>
> Closer?

Interfaces are not used to define utility classes because interfaces are
_not_ classes. Remember, an interface is simply a collection of method
_signatures_ (kind of like a procedure prototype in RPG). They describe a
standard protocol for interacting with objects that implement the interface.
However, there is no source code within the methods defined in the
interface. That code is the responsibility of whatever classes implement it.
Therefore, an interface may be created to define a certain set of behaviours
that a utility class _implements_, but the interface itself is not the
utility class.

Another way to think about it is to compare an interface to an electrical
outlet in your house. As an interface, the outlet defines a plug-shape,
voltage level, and polarity. But it doesn't supply the power! All it does is
provide a common interface for consumers of that power to access it. The
power could come from the local utility grid, your own generator, or
solar-panels. But where it comes from doesn't matter to your toaster or your
coffee-maker. The male power connector on the appliance is the means by
which the toaster "implements a" particular electrical "interface".

Hopefully, the previous example illustrates how interfaces help us to
provide more flexibility in our designs, by allowing "pluggability". They
loosen up the coupling between classes (the generator and the toaster),
which ultimately makes our design more interchangable. Wherever you add an
interface, you are in fact adding a plug-in point - a place where you can
plug in any object from any class that implements the interface.

The larger your system, the more important interfaces become.

Is it getting any clearer?


John Taylor
Canada



+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.