8 ms·
Given fn a foo a foo b foo c bar d bar e baz f baz g baz h and fn b foo bar baz
by kiitos 3y ago
Given
fn a
foo a
foo b
foo c
bar d
bar e
baz f
baz g
baz h
and
fn b
foo
bar
baz
fn foo
a
b
c
fn bar
d
e
fn baz
f
g
h
which of a or b is more readable and simpler? (Spoiler: it's almost always a.)
DRY isn't about repetition of text in a source file, it's about repetition of authority in your domain model. You evaluate it at an architectual level, not in PR diffs or whatever.
- laserlight 3y agoOf course fn a is simpler and more readable, simply because it's not 200-lines long and there are no indentations and there are no states to keep track of, etc. This example is not at all like a real code and is just a straw man of my argument. DRY at any architectural level corresponds naturally to repetition of text in source files.
- kiitos 3y ago> DRY at any architectural level corresponds naturally to repetition of text in source files. The "repeat" in "don't repeat yourself" refers to semantics (data and sources of truth) and not syntax (text in source files). This is a common misunderstanding, which is one of the things that tends to separate junior and senior engineers.
- laserlight 3y agoAgreed.