top | item 18775397

(no title)

Xyik | 7 years ago

Love this thread. I see this a lot, where engineers blindly follow best practices and have urges to re-factor code when its not necessary. Big files are not necessarily bad and I love that a lot of the comments are with me on this. Having to open several tabs and remembering where you are in the stack can be hard once there are more than a couple of frames / function calls in. There is a lot of benefit to keeping logic in 1 file or 1 function, and there is a time and a place for writing really granular DRY code. As with all engineering, there are always trade-offs to every decision and I think its about time we put to rest some of the traditional rules of thumbs and 'code smells' new engineers learn and adhere to like a bible.

discuss

order

jonahx|7 years ago

> As with all engineering, there are always trade-offs to every decision

This is the cliche that needs to be put to rest.

Yes, often there are tradeoffs. But just as often one thing is better than another thing, and there is no tradeoff.

A worldview in which everything has pros and cons and is ultimately subjective is fertile ground for entrenched habits, because it means never having to admit you're plain wrong, that there is a better way, or that other approaches are simply that much better than yours.

Xyik|7 years ago

I believe code design is ultimately subjective. Unlike other metrics like performance which can be easily and definitively measured, you can't easily measure 'good' code. The definition of 'good' changes based on the context of the code base and function the code is trying to achieve. In this case, choices like having giant functions and files is definitely subjective.

xendo|7 years ago

> everything has pros and cons and is ultimately subjective

That sound's awfully like postmodernism which is terrible everywhere it's applied, not only programming.