Assuming I have this class (Java code only for the sake of example):
class Person {
private String name;
public void setName(String name) {
this.name = name;
}
}
When I write documentation for this application and/or in-code documentation, what should I use to refer to a particular symbol, whether that be type, method or field?
When I describe a type, I usually say just "Person", keeping the casing of the type. When I refer to a method, I always do a dot: "Person.setName()". Depending on context, I might add the parameter list in order to be technically correct: "Person.setName(String)". I do not change the notation whether or not the method is static.
But field is a bit harder and I am not sure, despite being a programmer for many years now, that I have understood this part correctly. My heart want to always use a hash character: "Person#name". But I believe some of us use one or the other depending on context, whether or not the field is a static? And if so, which character to use when?
If dot is used, then the only disambiguation that exist between a field- and method reference is the presence of two parentheses, which in my mind is not enough. For example; "Person.name" is syntactically similar to "Person.setName()". But there's no commonality, in terms of special characters, between "Person#name" and "Person.setName()". Also, to my point.. is the fact that many of us are sloppy and actually refer to methods without parenthesis making the ambiguity absolute.
Also, if dot is supposed to be used in reference of a field, then some paragraphs of text will become rather awkward to read. For example:
Person is a class used in our application. A person has a Person.name. A person may also die.
Note that "name" is surrounded by a dot explosion. Versus:
Person is a class used in our application. A person has a Person#name. A person may also die.
All feed back is welcome. The answer that has a legit source or otherwise speak of community best practices is accepted. Me personally, I've googled but found nothing.