Ask HN: A Book or Course to Learn Code Quality/Structure?
I do however work for myself, and one downside to that is I don't work on (or even SEE) other people's code hardly ever. I feel like if I worked at a big company and stared at good code all day long I would have learned a lot by now.
I've read about things like "Single responsibility principle" or "Open-Closed Principle" which... while reading about it seems nice, it's always way more tricky in real life to apply (at least for me).
Looking at very simple "make_payment(user, 1000)" examples where the payment is consolidated into one line of code never helps me... in my experience, and the thing which I feel is hardest for my brain to wrap my head around, is when some parts of code is used in multiple areas, but there is no "clean break." Like say a "quick add to cart" function on a website... it might need to do all the following:
validate the cart, use toast modal dependencies with a custom message, track all items that were added to the cart, send different params to the backend, etc etc
This may be 80% similar to the "add to cart" so there could be a series of functions that seem easily 'shared', but then of course some other edge case will come up where I need to not track something now, so now do I make another function with duplication? Do I just keep adding arguments to a large already very confusing function?
Things like this I generally fumble my way through until it "feels right," as in I have a good intuition by now what will be a headache, and what wont. But I have no method to my madness, I just try to separate things as best I can but UNDOUBTEDLY there will be 89253 different "special cases" that make it very difficult to do it cleanly without either duplication, excessive arguments, excessively long functions, etc.
I do use OOP languages, and javascript primarily.
I want to just read a book or watch a course with GOOD examples. I absolutely dont feel my code is "bad", and I have managed some complex projects, but its not exceptionally good and that's where I want it to be.