According to Java’s commenting conventions, classes comments should describe a “thing”, rather than “actions”. It is easy when the class IS a thing (ex. a Clown), but what if it isn’t?
In this case, the ShapeProvider
is a proxy class that requests “stringified” Strings
to a small server application via the get
method. The string is then parsed to build a BaseShape
object, that is returned to the client of the service. The client simply draws the shape on a small GUI. This is a school work, so I’d want my comments to be as close as possible to the Java conventions.
/**
* How should I comment this?
*/
public class ShapeProvider extends ServerConnection{
/**
* Method comment that is okay.
*/
public BaseShape get(){
//Requests the shape
//Parses the response
//Use a Factory to create an instance of BaseShape
//Return it
}
}
Comments for a class that isn’t an entity
According to Java’s commenting conventions, classes comments should describe a “thing”, rather than “actions”. It is easy when the class IS a thing (ex. a Clown), but what if it isn’t?
In this case, the
ShapeProvider
is a proxy class that requests “stringified”Strings
to a small server application via theget
method. The string is then parsed to build aBaseShape
object, that is returned to the client of the service. The client simply draws the shape on a small GUI. This is a school work, so I’d want my comments to be as close as possible to the Java conventions.6
But your ShapeProvider is a thing!
How comes, you don’t see it as a thing? Your
ShapeProvider
is a someone who is responsible for providing you shapes while relying onX
andY
to do so. I think that is a acceptable commentation regarding the commenting conventions.But it shows you, that this code is actually not very well designed or named. Because why on earth would a
ShapeProvider
extend a ServerConnection? That’s just wrong. AShapeProvider
rather relies on some repository or repository connection and uses it to create the shapes.extends
should therefore not be used for this purpose at all!2
Filed under: softwareengineering - @ 19:44
Thẻ: class, comments
« How to model parallel processes (in a Bounded Context) with the same data store? ⇐ More Pages ⇒ Sudoku hidden sets algorithm »