Re: Own implementation of an interface



gabriel <petroleum@xxxxxxxxx> wrote:
My question is, how would i go about creating my own instance of this
interface so that the API utilises my methods instead of the blank,
skeleton ones already provided?
Is it simply Public interface myInterface extends APIInterfaceCLassNAMe?

You probably want public myClass implements APIInterfaceName. And provide
actual implementations of all the methods. If you write an interface, you can
declare methods but not actually implement any of them.

or is there some other method?
As far as java goes i've always been a little hazey around the concept
of interfaces, thus my confusion.

An interface is just a pure abstract class, with a slightly different syntax
for creating the subclass - you implement it rather than extending it.

Many frameworks provide both an interface and a convenience base class that
partially implements it and lets you override just the part you want to change
(like Swing's Action interface and AbstractAction class - you can implement
Action or extend AbstractAction, depending on your needs).

I haven't played with Robocode much, but I thought it did this as well - you
extend Robot (or AdvancedRobot) and override the methods that get called at
various events.
--
Mark Rafn dagon@xxxxxxxxx <http://www.dagon.net/>
.



Relevant Pages

  • Re: Learning Lisp design techniques (not just the language itself)?
    ... maximum compile-time checking of the usage of the API? ... How to define a package interface? ... Should you extend CLOS? ... objects with property lists? ...
    (comp.lang.lisp)
  • Re: [perfmon] Re: [perfmon2] perfmon2 merge news
    ... criticism of the current set of perfmon2 system calls, ... opposition to the goal of having strong typing of the interface. ... extend but that is at the expense of losing strong typing. ...
    (Linux-Kernel)
  • Re: Inheritance versus Composition
    ... you really need some poking around and see for yourself some examples of the trouble you run into by naively extending base classes which you can of course only do once. ... Its considered legacy today because IF you choose to use this mechanism, you can forget about having your data model extend anything else. ... Let the interface describe a notify mechanism and let your concrete class implement this. ...
    (comp.lang.java.help)
  • Design Aesthetics & Working With Portals
    ... room in one of the margins for a flag type of icon if I extend the ... within the portal's comfort zone. ... but they strain the intuitiveness of the interface. ...
    (comp.databases.filemaker)
  • Re: Interface delegates and implements
    ... > | I am trying to extend a set of GUI components with a set of common ... > | interface and the delegate that to the same class for all controls. ... Actually the whole delegate class instance is not being ...
    (borland.public.delphi.language.objectpascal)