× 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 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 ...

Follow-Ups:
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.