Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I do both, aided by Eclipse's autocomplete.</p> <p>First, I document the property:</p> <pre><code>/** * The {@link String} instance representing something. */ private String someString; </code></pre> <p>Then, I copy and paste this to the getter:</p> <pre><code>/** * The {@link String} instance representing something. */ public String getSomeString() { return someString; } </code></pre> <p>With eclipse, @return statements have an autocomplete - so, I add the word Gets, lowercase the "t", and copy the sentence with the lowercase "t". I then use @return (with Eclipse autocomplete), paste the sentence, and then uppercase the T in the return. It then looks like this:</p> <pre><code>/** * Gets the {@link String} instance representing something. * @return The {@link String} instance representing something. */ public String getSomeString() { return someString; } </code></pre> <p>Finally, I copy that documentation to the setter:</p> <pre><code>/** * Gets the {@link String} instance representing something. * @return The {@link String} instance representing something. */ public void setSomeString(String someString) { this.someString = someString; } </code></pre> <p>Then, I modify it and with Eclipse autocomplete you can get not only the @param tag but also the name of the parameter:</p> <pre><code>/** * Sets the {@link String} instance representing something. * @param someString The {@link String} instance representing something. */ public void setSomeString(String someString) { this.someString = someString; } </code></pre> <p>Then, I'm done. In my opinion, this templating makes it a lot easier, in the long run, to not only remind yourself what the property means through repetition, but also it makes it easier to add additional comments to the getter and setter if you want to add side effects (such as not allowing null properties, turning strings to uppercase, etc). I investigated making an Eclipse plugin for this purpose but I couldn't find the appropriate extension point for the JDT, so I gave up.</p> <p>Note that the sentence might not always start with a T - it's just the first letter has to be uncapitalized/recapitalized in pasting.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload