←back to thread

Against Best Practices

(www.arp242.net)
279 points ingve | 1 comments | | HN request time: 0.001s | source
Show context
vbezhenar ◴[] No.42171296[source]
How other engineering industries deal with this phenomena? Why those approach do not work with programming? I feel silly sometimes because software development is huge industry and we don't have consensus on basics.

For example I think that strict formatting is a good thing. Since I tried to use Prettier I'm using it and similar tools everywhere and I like it. I can't do vertical alignment anymore, it eats empty lines sometimes, but that's a good compromise.

May be there should be a good compromise when it comes to "best practices"? Like "DRY" is not always best, but it's always good enough, so extract common stuff every time, even if you feel it's not worth it.

I often deal with this dilemma when writing Java with default Idea inspections. They highlight duplicated code and now I need to either disable this inspection in some way or extract the chunk of code that I don't really think should be extracted, but I just can do it and move on...

replies(12): >>42171363 #>>42171370 #>>42171393 #>>42171459 #>>42171531 #>>42171554 #>>42171817 #>>42171829 #>>42172784 #>>42173289 #>>42173799 #>>42174046 #
cjblomqvist ◴[] No.42171817[source]
A nit; DRY is probably not what you think it is. DRY is basically the same as SRP, framed differently. In SRP, it's totally valid to have the code twice if it has different meaning from a user pov.
replies(3): >>42171937 #>>42172010 #>>42180770 #
1. deathanatos ◴[] No.42180770[source]
I think it's the same thing, but I usually postulate DRY as semantically identical code, not merely syntactically identical.

"Byte for byte equivalent" doesn't necessarily mean it's a copy, if the semantics of it are different.