Of Abstract convention and Marker interface

?

-

Is it a convention to prefix "Abstract" to all abstract classes? I have
come across several classes in the java api that do not adhere to this
convention.

If I were to do that, I have to resort to creating a marker interface so
that I can do a someMethod(SomeClass someClass) rather than
someMethod(AbstractSomeClass asc) - which looks akward.
 
S

Stefan Schulz

Is it a convention to prefix "Abstract" to all abstract classes? I have
come across several classes in the java api that do not adhere to this
convention.

If I were to do that, I have to resort to creating a marker interface so
that I can do a someMethod(SomeClass someClass) rather than
someMethod(AbstractSomeClass asc) - which looks akward.

Not at all. Not all abstract classes are called Abstract*. The classes
that do, however, do not usually implement marker interfaces, but
implement some part of an interface while leaving other parts of the
interface unimplemented (hence the abstract)
 
T

Thomas G. Marshall

Stefan Schulz coughed up:
Not at all. Not all abstract classes are called Abstract*.

No, but I would strongly suggest it as a convention. It's the clearest
mechanism I've seen, and it's what I do religiously. The only problem I
know of is that it groups lexically with all the other Abstract*.java files
in your directory, which may be either a good or bad thing depending on what
you're used to.

Furthermore, all interfaces should have something "done" to their name as
well. Many folks go with an "I" appendage. I go personally always go
overboard with "*Interface.java".

I know, I know, ....



The classes
that do, however, do not usually implement marker interfaces, but
implement some part of an interface while leaving other parts of the
interface unimplemented (hence the abstract)



--
Having a dog that is a purebred does not qualify it for breeding. Dogs
need to have several generations of clearances for various illnesses
before being bred. If you are breeding dogs without taking care as to
the genetic quality of the dog (again, being purebred is *not* enough),
you are what is known as a "backyard breeder" and are part of the
problem. Most of the congenital problems of present day dogs are
traceable directly to backyard breeding. Spay or neuter your pet
responsibly, and don't just think that you're somehow the exception and
can breed a dog without taking the care described.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top