FORMATTER BARRIER
Tools already treats comments as layout anchors!
Just compare:
public static <D extends IcdCodeGet & Comparable<D>, L extends IcdListAccess & Comparable<L>> IcdCodeGet[] getBestCodes( //
ComparableList<ComparableLink<L, IcdCodeGet[]>> bests //
, L list //
, boolean renew //
, ExtendedIterator<CounterCmp<D>> statsSource) {...}
public static <D extends IcdCodeGet & Comparable<D>, L extends IcdListAccess & Comparable<L>> IcdCodeGet[] getBestCodes( ComparableList<ComparableLink<L, IcdCodeGet[]>> bests, L list, boolean renew, ExtendedIterator<CounterCmp<D>> statsSource) {...}
ORIGIN
Old line-length standards were designed for old code styles, not modern ones.
The 80-character rule made sense when:
- identifiers were short,
- types were shallow,
- logic was procedural
- and screens were literally 80 columns wide.
If you tell a formatter to always break lines "when it seems useful", you end up with code that looks like:
a long sentence
with each word
on a new line
- unstable blobs of code,
- massive diffs from tiny changes,
- and layouts that lose all semantic structure.
final AsynchronousEventStreamProcessor<
ExtremelySpecificBusinessInvariant,
AnotherPainfullyDescriptiveType,
Map<String, List<Optional<Thing>>
> eventStreamProcessor =
someFactory.create(...);
final AsynchronousEventStreamProcessor<ExtremelySpecificBusinessInvariant, AnotherPainfullyDescriptiveType, Map<String, List<Optional<Thing>>>> eventStreamProcessor = someFactory.create(...);
None communicates any structure - as all code will look the same.
- Too many breaks - only ~20% of the code is visible, no flow, no locality.
- Too few breaks - unreadable horizontal blobs that reformat chaotically.
- artificially limiting the number of parameters
- splitting methods just to shorten names
- using one-letter generic parameters
- collapsing meaning to satisfy formatting tools
We already solved this once — but it was forgotten. Long ago, ; acted as a visual separator. Statements ended clearly. Structure was obvious.
As we moved toward:
- fluent APIs,
- streams,
- method chaining,
To project structure into code, I intentionally use:
- explicit line breaks
- semantic grouping
- when necessary
Breaking lines adds meaning when:
- Parameters in declarations
They define what a method does - split them when they carry meaning. - Parameters belonging to multiple logical scopes
Break by scope - reviewers instantly see intent in diffs. - Large collections (e.g. 300 strings)
Break by first character - searchable, scannable, maintainable. - Complex logical expressions in if statements
Break as much as needed until logic becomes obvious.
That is the main metric that matters.
Ofcourse it’s will be useless for DTO-style programming.
0 comments / komentarz(y):
Post a Comment