Re: Alignment Nazi?
John Carter <[email protected]>
| Newsgroups | gmane.comp.programming.language-of-the-year |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 27 Apr 2008, gjmilne64 wrote: > I am an Alignment Nazi. When I see a block of code like this: Hi! Greetings Mr Alignment Nazi. I'm Mr Object Design Nazi! :-)) When I see long lists requiring alignment like... > 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 say... "Cwap! Isn't there an easier way? Aren't bunches of these things part of the same object? Shouldn't a copy constructor or a factory or _something_ _anything_ save me from all this? Maybe some of this calculation doesn't belong in the routine anyway, it probably should be a method on one of these objects I pulling crap out of... Instead of going get this, that, get tom, dick and harry, and theOther from an object and then calcExpression( this, that, tom, dick harry, theOther) perhaps I should say... this.calcExpression(theOther) Yes, I keep my code aligned... but large blocks of aligned stuff bug me. It tells me I missing an opportunity to do better. > Perhaps I should write a book (or blog) on the merits of "Pretty Code". It should be a side note in a book on Law of Demeter, Coupling and cohesion. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : [email protected] New Zealand