I like dlang but i don't like dub

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 21 20:12:48 UTC 2022


On Sun, Mar 20, 2022 at 07:51:38AM -0700, Ali Çehreli via Digitalmars-d-learn wrote:
> On 3/20/22 05:27, Adam D Ruppe wrote:
> 
> > So if it just coincidentally happens to be the same code, I'd
> > actually rather copy/paste it than import it.
> 
> This is very interesting because it is so much against common
> guidelines. I first read about such copy/paste in a book (my guess is
> John Lakos's Large Scale C++ Software Design book because my next
> example below is from that book.) The author was saying exactly the
> same thing: Yes, copy/paste is bad but dependencies are bad as well.

Yeah, IME it goes both ways.  I've encountered situations of what I
might call "mindless cut-n-paste", in which a utility function clearly
shared across multiple modules was mindlessly copied across 8-12
different files, bugs and all.  Several subsequent bugfixes repaired
most, but not all, of each copy, each bugfix touching a different set of
functions, ending up with multiple mutations of the same original
function, with several different combinations of remaining bugs.  The
icing on top was that there was *already* a common utility module that
contained commonly-used functions, but for some reason nobody bothered
to move the functions there.

(And the icing on top of the icing was that at some subsequent point
somebody else came along and reinvented the same function under a
different name with a slightly different API, thus making an already bad
problem worse.)

On the other side of the spectrum, though, I've also seen code that
needed some function F defined in some library L, that function being
the *only* thing needed from L, yet because of the dogma of code reuse,
L was linked in its entirety, recursive dependencies and all, causing
needless code bloatage and build complexity.  Perhaps a copy-n-paste
would've been a better solution in this situation.


[...]
> Engineering almost by definition should break guidelines.
[...]

This one's going into my quotes file. ;-)


T

-- 
Hey, anyone can ignore me and go ahead and do it that way. I wish you
the best of luck -- sometimes us old coots are dead wrong -- but forgive
me if I'm not going to be terribly sympathetic if you ignore my advice
and things go badly! -- Walter Bright


More information about the Digitalmars-d-learn mailing list