× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




Hi Thorbjørn,

Commenting the end of a long if expression, method or class is simply a
device to help me get around better and more quickly in code. Whether
indented properly or not, my eyes tend to glaze over when I see:

}
}
}
}
}

so I do things like this:
}
} // end if local or remote
} // end if customer or applicant
} // end if validated
} // end process()

One often sees recommendations that class code shouldn't go past one
page. I won't argue either way, but that's not the way it is in the real
world, so one builds coping devices. As I mentioned before, it's automatic
for me now on code of any length, and I regard it as cheap insurance against
structural bugs.

I completely agree with you about comments like:
// process the transaction
processTransaction();

but the end of block comments above are much more about mechanical
correctness of code and code traversal.

I don't think it has anything to do with AS/400 programming, although
that might have had a subconcious impact.

As for editors, I recently had to work on a project that still used
JSP's, and had lots of embedded Java code. I also had to use Eclipse since
that was the client's tool of choice. NetBeans will highlight the braces at
beginning and end of block, but Eclipse won't (at least not out of the box.)
Additionally, I'm not aware of any editor that will clean up Java code
embedded in JSP's.

So, as a consultant, there are many things I do that seem unusual or
redundant to developers who have worked in only one or two shops. One of my
favorites on the AS/400 is that I almost always go immediately to the
command line and use standard AS/400 commands. A client programmer almost
always says "don't put in the entire command, just call 'mypet'." What they
don't understand is that the next shop does it entirely differently with
'mymammal'. So I use what always works. In general, my usage and style are
aimed at overall productivity and efficiency for both individual and
multiple clients.


Joe Sam

Joe Sam Shirah - http://www.conceptgo.com
conceptGO - Consulting/Development/Outsourcing
Java Filter Forum: http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International? http://www.jguru.com/faq/I18N
Que Java400? http://www.jguru.com/faq/Java400

----- Original Message ----- From: "Thorbjørn Ravn Andersen" <thunderaxiom@xxxxxxxxxxx>
To: "'Java Programming on and around the IBM i'" <java400-l@xxxxxxxxxxxx>
Sent: Monday, February 28, 2011 3:20 AM
Subject: RE: Is String.split() broken?


Hi Joe.

I am not interested in a code style war, but I am - sincerely, honestly -
interested in hearing why people choose to do it this way (because I
inherited a large codebase in this style). Thanks for a thorough answer.

Would a possible cause be because you are used to a programming world where
a generic editor is used, and there is no easy reformatting step possible
which would fix aligning and put brackets in their right position? After
being bitten several times, you found that these comments help you
remembering to fix aligning?

Or is it because you come to Java from a language where there is keywords
instead of brackets to indicate blocks, so you would end on "END-IF" or
"END-LOOP" making it easier to see where it matches?

Or is it simply because you are used to only having a few lines of code
visible in your editor, so you simply cannot _see_ where the bracket
belongs, and having a comment helps?

If others do this kind of commenting, I would appreciate hearing why they
have chosen to do so :) Again, not for the code war, but to become a little
more educated.


Regarding the maintenance work, I agree that having to maintain code gives
you a different perspective on what is important and what is not.
Personally, it lead me to understand that _WHY_-comments are crucial, and
_HOW_-comments are usually redundant.

Compare
// add 1 to i
to
// we must use our own sort routine, as it is very expensive to swap two
// items. The provided FooSort swaps each element only once into its final
place.

You essentially need to have had to maintain software to realize the
difference, and why it is important. In an AS/400 shop, it comes pretty
easily because the platform is so stable that programs, even Java programs,
can live for years without the platform forcing changes on you. The other
day I had to fix a minor bug in a Java-program I put in production about 5
years ago, which was very interesting, simply because there were so many
experiences not done yet :)






-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Joe Sam Shirah
Sent: 28. februar 2011 02:10
To: Java Programming on and around the IBM i
Subject: Re: Is String.split() broken?


Hi Thorbjoern,

Note: I'm not interested in a code style war and won't respond to same.
I was asked a question and here's my answer. It applies to me. Do your own
thing.

how come you comment your closing brackets?

For the same reason I comment anything, and the same reason I do a
number of code things automatically: readability, understandability (and the

efficiency that brings,) and correctness. Clearly it doesn't much matter
here, but when a classs contains lots of large methods it becomes helpful.

I also comment large if/else statements. Once you've been in braces
hell a few times, you try to prevent it. I've worked with lots of code by
lots of programmers, as we've done many projects for many clients, and
believe me, everything helps. So, you'll never see me write:

if( x )
doThis();

instead it will always be:

if( x )
{
doThis();
}

If it's not obvious why, it's because it is too easy for someone else to to
this:

if( x )
doThis();
doThat();

and wonder why doThat(); always happens. I'm sure you wouldn't, but I
guarantee someone else will. So this stuff is cheap insurance.

And yes, I line up braces for the same reason.

What I will happily discuss at length, if anyone wants to, is my theory
that all programmers should do maintenance work at least 25% (pick your
percentage) of the time. There are lots of shops that have developers and
maintenance programmers; the developers never do maintenance and
vice-versa.. Once you're forced to maintain code, it gives you a different
perspective on development.

One of the great things about an AS/400 background is that typically
shops have been so small that one was forced to work in all areas. That's a

reason why we tell clients that we can, and often do, take a project from an

idea through installation and training, or do any part. I remember being
amazed the first time I came across an RPG programmer who didn't know CL.


Joe Sam

Joe Sam Shirah - http://www.conceptgo.com
conceptGO - Consulting/Development/Outsourcing
Java Filter Forum: http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International? http://www.jguru.com/faq/I18N
Que Java400? http://www.jguru.com/faq/Java400

----- Original Message ----- From: "Thorbjoern Ravn Andersen" <ravn@xxxxxxxxxx>
To: "Java Programming on and around the IBM i" <java400-l@xxxxxxxxxxxx>
Sent: Sunday, February 27, 2011 5:05 PM
Subject: Re: Is String.split() broken?


Den 27/02/11 18.46, Joe Sam Shirah skrev:
} // end main

} // end class xxxSplit

Regexp'es are always fun.

Out of curiosity, how come you comment your closing brackets? An
AS/400 programmer habit?


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.