Designation of a non-static method

Discussion in 'Java' started by Stefan Ram, Dec 20, 2012.

  1. Stefan Ram

    Stefan Ram Guest

    I used to think that it was common usage to use »C.f()« for
    a static method »f()« and »C#f()« for a non-static method
    »f()« of a class »C«.

    Yet, in

    http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

    , there is a reference »Random.nextDouble()« given
    (at the end of the expanded documentation of »random()«),
    that refers to the non-static method

    http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextDouble()

    . So is this now the official Java style to designate
    even a non-static method »f()« of a class C by »C.f()«?
     
    Stefan Ram, Dec 20, 2012
    #1
    1. Advertising

  2. Stefan Ram

    Eric Sosman Guest

    On 12/20/2012 2:06 PM, Stefan Ram wrote:
    > I used to think that it was common usage to use »C.f()« for
    > a static method »f()« and »C#f()« for a non-static method
    > »f()« of a class »C«.
    >
    > Yet, in
    >
    > http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html
    >
    > , there is a reference »Random.nextDouble()« given
    > (at the end of the expanded documentation of »random()«),
    > that refers to the non-static method
    >
    > http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextDouble()
    >
    > . So is this now the official Java style to designate
    > even a non-static method »f()« of a class C by »C.f()«?


    Don't fret about it.

    "A foolish consistency is the hobgoblin of little minds,
    adored by little statesmen and philosophers and divines."
    -- RWE, "Self-Reliance"

    --
    Eric Sosman
    d
     
    Eric Sosman, Dec 20, 2012
    #2
    1. Advertising

  3. Stefan Ram

    Lew Guest

    Stefan Ram wrote:
    > I used to think that it was common usage to use »C.f()« for
    > a static method »f()« and »C#f()« for a non-static method
    > »f()« of a class »C«.


    AFAIK it still is.

    > Yet, in
    > http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html
    > , there is a reference »Random.nextDouble()« given
    > (at the end of the expanded documentation of »random()«),
    > that refers to the non-static method
    > http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextDouble()
    >
    > . So is this now the official Java style to designate
    > even a non-static method »f()« of a class C by »C.f()«?


    No.

    Was it ever the official style to do it the common way?

    I have not seen the "#/." convention universally employed, although I have observed
    that it is common, particularly among more experienced and competent Java developers.

    I have never seen it proffered as an official standard. Could you point to a reference
    that it is or ever was?

    --
    Lew
     
    Lew, Dec 20, 2012
    #3
  4. Stefan Ram

    Jan Burse Guest

    Stefan Ram schrieb:
    > I used to think that it was common usage to use »C.f()« for
    > a static method »f()« and »C#f()« for a non-static method
    > »f()« of a class »C«.
    > [Snip]


    I find in the Java source code:

    * @see Random#nextDouble()

    I find in the HTML source code:

    <a
    href="../../java/util/Random.html#nextDouble()"><code>Random.nextDouble()</code></a>

    I guess the HTML doc was generated via a doclet. The doclet
    that was used for JDK 1.4 did already do the same transformation
    of Java source code, into Java HTML javadoc. You can check for yourself:

    http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#random()

    This has not changed since then for JDK 1.7:

    http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#random()

    Bye
     
    Jan Burse, Dec 20, 2012
    #4
  5. Stefan Ram

    Jan Burse Guest

    Hi,

    For a java comment {@link Integer#MIN_VALUE} you also see
    magically morph the hash (#) into a period (.).

    This is all done by javadoc. The source of javadoc is open.
    For example the see tag is defined here:

    http://javasourcecode.org/html/open-source/jdk/jdk-6u23/com/sun/tools/javadoc/SeeTagImpl.java.html

    The syntax of a @see tag is:

    <where>#<what>

    Whereby <where> is resolved into a ClassDoc or PackageDoc
    and <what> is resolved into a MemberDoc.

    Bye

    Jan Burse schrieb:
    > Stefan Ram schrieb:
    >> I used to think that it was common usage to use »C.f()« for
    >> a static method »f()« and »C#f()« for a non-static method
    >> »f()« of a class »C«.
    >> [Snip]

    >
    > I find in the Java source code:
    >
    > * @see Random#nextDouble()
    >
    > I find in the HTML source code:
    >
    > <a
    > href="../../java/util/Random.html#nextDouble()"><code>Random.nextDouble()</code></a>
    >
    >
    > I guess the HTML doc was generated via a doclet. The doclet
    > that was used for JDK 1.4 did already do the same transformation
    > of Java source code, into Java HTML javadoc. You can check for yourself:
    >
    > http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html#random()
    >
    >
    > This has not changed since then for JDK 1.7:
    >
    > http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#random()
    >
    > Bye
     
    Jan Burse, Dec 20, 2012
    #5
  6. Stefan Ram

    Roedy Green Guest

    On 20 Dec 2012 19:06:03 GMT, -berlin.de (Stefan Ram)
    wrote, quoted or indirectly quoted someone who said :

    > I used to think that it was common usage to use »C.f()« for
    > a static method »f()« and »C#f()« for a non-static method
    > »f()« of a class »C«.


    Random.nextDouble will not compile, but that is how the method is
    named in JavaDoc. I suppose JavaDoc could be changed to generate
    random.nextDouble to hint at the instanceness. On the other hand, you
    will get a warning if you do someobject.somestatic().
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    Students who hire or con others to do their homework are as foolish
    as couch potatoes who hire others to go to the gym for them.
     
    Roedy Green, Dec 20, 2012
    #6
    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. Alan
    Replies:
    5
    Views:
    288
    Mark Rafn
    Nov 30, 2007
  2. Fresh Jobs For Softwares Engg

    Designation - Jr. Software Engineer(QA)

    Fresh Jobs For Softwares Engg, Apr 14, 2008, in forum: C++
    Replies:
    0
    Views:
    487
    Fresh Jobs For Softwares Engg
    Apr 14, 2008
  3. ......ADMISSION IN TOP 10 IIT's and ENGINNERING CO

    Req. Designation - Jr. Software Engineer(QA)

    ......ADMISSION IN TOP 10 IIT's and ENGINNERING CO, Apr 15, 2008, in forum: Python
    Replies:
    0
    Views:
    311
    ......ADMISSION IN TOP 10 IIT's and ENGINNERING CO
    Apr 15, 2008
  4. rickman
    Replies:
    5
    Views:
    470
    rickman
    Mar 30, 2013
  5. Replies:
    1
    Views:
    226
Loading...

Share This Page