Of Abstract convention and Marker interface

Discussion in 'Java' started by -, Jul 7, 2005.

  1. -

    - Guest

    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.
     
    -, Jul 7, 2005
    #1
    1. Advertising

  2. On Thu, 07 Jul 2005 11:25:48 +0800, - wrote:

    > 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)

    --
    You can't run away forever,
    But there's nothing wrong with getting a good head start.
    --- Jim Steinman, "Rock and Roll Dreams Come Through"
     
    Stefan Schulz, Jul 7, 2005
    #2
    1. Advertising

  3. Stefan Schulz coughed up:
    > On Thu, 07 Jul 2005 11:25:48 +0800, - wrote:
    >
    >> 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*.


    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.
     
    Thomas G. Marshall, Jul 12, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    6
    Views:
    35,562
    ksamir2004
    Jun 20, 2007
  2. Sameer
    Replies:
    4
    Views:
    631
    Roedy Green
    Aug 31, 2005
  3. lsrinu

    Marker Interface

    lsrinu, Jun 6, 2006, in forum: Java
    Replies:
    1
    Views:
    2,944
    jmcgill
    Jun 6, 2006
  4. Replies:
    4
    Views:
    863
    Rolf Magnus
    May 17, 2006
  5. Replies:
    2
    Views:
    553
Loading...

Share This Page