On 21/12/2007, at 12:04 AM, rob@xxxxxxxxx wrote:
Depends on what you mean by 'end of line' comments. I agree that
most of
the little blurbs at the end of RPGIII are worthless. Especially the
loathsome genre of "add X + Y".
That is what I had in mind--comments of the sort "increment counter".
Duh! I can tell that from the code. What I want from the comment is WHY.
However, some of the end of line comments in free format aren't bad.
qusdltus(UserSpace:errc0100);
if ExceptionId<>*blanks and ExceptionID<>'CPF2105'; //
CPF2105 =
not found
// ERROR: What should we do?
Select;
...
EndSl;
EndIf;
Better, but that could also be done in RPG III style end-of-line
comments. The "proper" way to code the above is:
D OBJ_NOT_FOUND C CONST('CPF2105')
if ( ExceptionID <> *BLANKS AND ExceptionID <> OBJ_NOT_FOUND );
which immediately removes the need for the 'useless' end-of-line
comment.
So, would a tool count that as one comment line, or two?
That would depend on the design of such a tool. I do know that the
rules used by such tools can be quite different for different
languages--and in some cases quite complex. If I wrote such a tool
for RPG then I would not count ENDxx statements as LOC because they
are really statement terminators and the statement itself (IF, DO,
FOR, SELECT, etc.) has already been counted. ENDxx in RPG serves the
same purpose as { and } in C and aren't really code. The only
possible exception is if the ENDxx has a value in Factor 2 in which
case it is code. I would probably also count KLIST/KFLD, PLIST/PARM
and CALL/PARM combinations as 1 line of code.
I think that if the tool counts comments separately from code (as it
should) then your example has two comment lines.
Or, both a code line and a comment line?
Yes, but I doubt anyone would separate the count as such:
o Count of comments
o Count of code
o Count of code with end-of-line comment
doesn't seem to add much value.
Thus the total may exceed the number of source lines?
Yes. Thus your example (ignoring the omitted code represented by the
ellipses) has:
5 LOC plus 2 comments
or
3 LOC plus 2 comments (if ENDxx are ignored)
Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists
http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.