11 ms·
> But of course I meant my earlier comment particularly for quite complex methods that had very ambiguous behaviour unless defined in a comment that could act a
by AnthonyMouse 13y ago
> But of course I meant my earlier comment particularly for quite complex methods that had very ambiguous behaviour unless defined in a comment that could act as a contract.
Which is kind of the point. You do need some kind of documentation for nontrivial methods. But requiring boilerplate documentation for everything encourages the opposite of that because it becomes "fill in the fields" rather than "say something useful." I mean let's say you're right and SetRelativePosition isn't clear about what it's relative to. Which of these is better?
/**
* SetRelativePosition sets the Shape relative position
*
* @param x The relative X coordinate
* @param y The relative Y coordinate
* @param units The units of the coordinates
* @returns Void
*/
void SetRelativePosition(int x, int y, LengthUnit units = LengthUnit::PIXELS);
-or-
/* SetRelativePosition: sets position relative to current position */
void SetRelativePosition(int x, int y, LengthUnit units = LengthUnit::PIXELS);