Simple Getter/Setter comments

前端 未结 14 1035
悲&欢浪女
悲&欢浪女 2020-12-04 07:16

What convention do you use to comment getters and setters? This is something I\'ve wondered for quite some time, for instance:

/**
 * (1a) what do you put h         


        
14条回答
  •  Happy的楠姐
    2020-12-04 07:29

    If there isn't special operation in getter/setter I usually write :

    With Javadoc (with private option):

    /** Set {@see #salary}. @param {@link #salary}. */
    public void setSalary(float salary);
    

    and/or

    /** 
     * Get {@see #salary}.
     * @return {@link #salary}.
     */
    public float salary();
    

    With Doxygen (with private extract option):

    /** @param[in] #salary. */
    public void setSalary(float salary);
    
    /** @return #salary. */
    public float salary();
    

提交回复
热议问题