Re: Using Interfaces ?
- From: Lew <lew@xxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 25 Feb 2007 10:01:59 -0500
TonyB wrote:
I think I've answered my own question. An interface is really declaring a type for a class's methods , so that when I use a class based on that interface, it is type checked that it meets the requirements defined in the interface ?
So I could say
exampleinterface object 1 ;
exampleinterface object 2 ;
...
object1 = new example1class();
object2 = new example2class();
If this compiles I know that both objects implement the required methods.
Do I understand this correctly ?
Yes.
One small note: there is a nearly universal convention in Java for laying out source code and for nomenclature.
<http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html>
Class names should start with an upper-case letter, variable and method names with a lower-case letter. Each subsequent word part within a name also begins with an upper-case letter.
As a matter of engineering, it is bad practice to include things like "class" in a class name, "object" in an object name, "interface" in an interface name.
You might refer a class to an interface or vice versa, and to have to change the name is silly. All objects are objects, so saying "object" is unnecessary.
- Lew
.
- Follow-Ups:
- Re: Using Interfaces ?
- From: Lew
- Re: Using Interfaces ?
- References:
- Using Interfaces ?
- From: TonyB
- Re: Using Interfaces ?
- From: TonyB
- Using Interfaces ?
- Prev by Date: Re: Using Interfaces ?
- Next by Date: Re: Checking input for letters
- Previous by thread: Re: Using Interfaces ?
- Next by thread: Re: Using Interfaces ?
- Index(es):
Relevant Pages
|