Hacker News new | ask | show | jobs
by advael 1702 days ago
It seems like every few months I read some new way of articulating the idea that code that's hard to maintain and modify is frustrating. Some, like this, don't really pose solutions, some do, but most I think fail to realize that their advice inevitably falls apart in some case

Extremely modular/functional code can require understanding more separated moving pieces, which may well be scattered to the winds in a zillion different files and combined in clever but counterintuitive ways

Extremely object-oriented code has lots of mutability, inheritance, and encapsulation gotchas that make users of an API less likely to understand what's happening under the hood of some class

Extremely terse code can be difficult to parse the logic out of, extremely verbose code can take forever to read and be hard to hold in your head, extremely abstract code can be hard to parse out how it accomplishes the application, extremely purpose-specific code can be ridiculously idiosyncratic and be hard to separate into digestible pieces, and so on and so forth. I've heard a lot of code organization advice and could keep doing this for hours.

I had a student tell me a personal project's codebase looked like the necronomicon once after an overhaul I made to make it more readable from my perspective

There are sometimes takeaways from all these analogies and policies and just generally opinions about how to write code people can supposedly maintain or modify or read more easily, and I definitely use and take some of them to heart. But most advice is really bad at generalizing, and I often feel that the most readable style of code is whatever one that I prefer and can convince people who work with me on it to prefer (Or, you know, vice versa as the case may be)

1 comments

I agree. What is easy to understand for you depends on your experience, personality etc. I have been told many times by experienced developers that my code is straightforward and easy to understand and maintain. However I have also been told by some inexperienced developers that I am “doing it wrong” because I am not following whatever pattern or silver bullet is currently hyped/fashionable on HN. Which always amuse me. It’s like a young inexperienced virgin trying to teach me about sex based on what he/she has read in the latest fashion magazine.