Java’s Terseness
2020-04-22, post № 228
Java, programming, #anti-pattern, #anti-patternism
Whilst pondering the lost control one has over pastebin posts as a guest; the inability to remove a text one has published themselves and the entailed virtually temporally unbounded availability to anyone of this text, I decided to look at pastebin’s “archive” site — a chronologically sorted collection of the most recent public pastebin posts.
One interesting post was titled Filter — Stringrid — Delphi and appears to be a Delphi program with German comments accomplishing some two-dimensional array manipulation task.
However, when looking further down the archive, a post published around two minutes earlier caught my attention — exmp1 [1]. This innocuously titled Java source file upon closer contains inspection an impressive 𝟥𝟦𝟫 lines of code. Now, source files of such a line count are not unreasonable (especially when writing Java), however it is not the typical size of an example — as this paste’s title suggests.
Thus, I decided to read it to know what it is meant to accomplish and how it is written — the source’s line count is highly misleading regarding its functionality.
This Java program asks the user for an integer, rejects it if it is not in the range [0, 999]
and attempts to print an English numeral representation of said integer. Ignoring the lack of newlines and non-hyphenation on a functional level, the implementation seems to be driven by pure anti-patternism, possibly interpreting “DRY” as “Do Righteously Yank”.
I am often baffled by the sheer effort most likely put into copying hundreds of lines and meticulously editing each one in a repetitive manner — unless, of course, this file was auto-generated by some anti-patternizer; which did have some appeal.
Anyway, have a look at the paste, try it out online and take a look at an implementation of intToEnglishNumeral by myself.