Alignment Nazi?

"gjmilne64" <[email protected]>
Newsgroups gmane.comp.programming.language-of-the-year
Message-ID <[email protected]>
Hi!

I am an Alignment Nazi. When I see a block of code like this:

         final int         counts              = result.getCounts();
         final int         periodMicros        = result.getMicros();
         final Rate        rate                = new Rate(new
Duration(periodMicros, Duration.MICROSECOND), counts);
         final Current     reagentIntensity    =
upsElectrometer.getValue();
         final Current     productIntensity    =
dwsElectrometer.getValue();
         final Temperature flowtubeTemperature =
flowtubeThermocouple.getValue();
         final Pressure    flowtubePressure    =
flowtubePressureGauge.getValue();
         final FlowRate carrierFlow = reagent.getIon().isPositive() ?
pcgFlowMeter.getValue() : nicgFlowMeter.getValue();
         final FlowRate sampleFlow   = sampleFlowMeter.getValue();
         final Duration reactionTime = getReactionTime(carrierFlow);
         final Lut ICF_LUT =
CONFIG.getLut(DefaultConfigIfc.ConfigId.ION_ICF_LUT);

I find it so much easier to read when I change it to this:

         final int         counts              = result.getCounts();
         final int         periodMicros        = result.getMicros();
         final Rate        rate                = new Rate(new
Duration(periodMicros, Duration.MICROSECOND), counts);
         final Current     reagentIntensity    =
upsElectrometer.getValue();
         final Current     productIntensity    =
dwsElectrometer.getValue();
         final Temperature flowtubeTemperature =
flowtubeThermocouple.getValue();
         final Pressure    flowtubePressure    =
flowtubePressureGauge.getValue();
         final FlowRate    carrierFlow         =
reagent.getIon().isPositive() ? pcgFlowMeter.getValue() :
nicgFlowMeter.getValue();
         final FlowRate    sampleFlow          =
sampleFlowMeter.getValue();
         final Duration    reactionTime        =
getReactionTime(carrierFlow);
         final Lut         ICF_LUT             =
CONFIG.getLut(DefaultConfigIfc.ConfigId.ION_ICF_LUT);

Of course, this works so long as you use a monospaced font in your
editor.

The question I want to ask is "does my need for visual clarity excuse my
fetish for alignment of equals signs in blocks of code"?

My personal justification is that I can more easily assimilate the block
of code if the left-hand side of variable names is clearly separated
from the right-hand side of assignments. I don't know why my brain finds
this easier, it just does. What amazes me, however, is how many of those
I have worked with over the years have no problem with the the former
code layout.

Perhaps I should write a book (or blog) on the merits of "Pretty Code".

Regards,

Gordon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.