What books would you recommend? I find it hard to learn real world patterns and codebases.
Smaller patterns like inheritance, composition, traits, functional monads, async coroutines, RAII, MVVM, dependency injection, and semaphore synchronization, are easy to learn, but seemingly unhelpful in the grander scheme. Nobody seems to completely adhere to the rules. As a result, these small patterns never seem to lead to clean code.
I loved coding as a child and pursued CompSci in college. But having worked a few years in the industry, I really think I do not know how to solve anything. At one point I felt as if everyone is gaslighting me. But if multiple people from different companies say I need to learn, then I should.
Right now I want to read to know what exactly I am missing in my knowledge about how code works in large codebases
> (...) are easy to learn, but seemingly unhelpful in the grander scheme. Nobody seems to completely adhere to the rules. As a result, these small patterns never seem to lead to clean code.
Good. That is very useful state of mind to be in.
Because these things do not produce cleaner code. They are tools to solve problems.
Coders are like photographers. The ones who like talk the most shoot walls head on and then peep at pixels and mostly discuss hardware. The ones who know how to make good photos do not care about who uses what kind of camera. A camera is just a tool to capture light field.
Clean code is what happens in your mind and as a result of your mental process.
Patterns, composition, inheritance tricks, and so on -- these are things you add to your toolbelt to use it when it is needed. You should continue adding tools to your toolbelt to be able to solve wider variety of problems and have more alternative solutions. But on its own, more tools do not mean mastery and do not lead to clean code.
If anything, more tools without knowledge how to use them leads to less readable code. This happened to me for the first half of my career..
What get you to mastery is by building taste for simple code and ability to self reflect on your work. Taste for simple code means you know why code needs to be simple and you know how clean code looks like.
Self reflection is trying to be objective and judgy about your results. When you write the code, you keep refactoring until you like the results. You write a module, then you polish it until there is nothing else to remove and it does exactly what it is supposed to be doing. You do it long enough and you will have experience to start it closer to a clean result. You may never get to be able to write clean code on the first try but you might get better at having much cleaner first approximation.
Ideally, you also take some responsibility longer term for what you produced. You compare your initial ideas with how they fared over time. You learn some things you thought smart weren't so smart at all. You learn what works and what doesn't work in general.
There is one more way and this is mentoring. I do pair programming with people where we design and implement solutions to progress. Lets me get to know the person better and the person gets to observe the process which can be a huge shortcut in the process of learning to write clean code.
I found the book Growing Object-Oriented Software Guided by Tests to be very inspiring. The book demonstrates how to evolve the code architecture, how and when to add new concepts and abstractions, how to listen to the tests, when to refactor etc. The tech in the examples is dated, but the gist of the book is very relevant.
Another classics are:
- Working effectively with legacy code
- Refactoring: Improving the Design of Existing Code
What books would you recommend? I find it hard to learn real world patterns and codebases.
Smaller patterns like inheritance, composition, traits, functional monads, async coroutines, RAII, MVVM, dependency injection, and semaphore synchronization, are easy to learn, but seemingly unhelpful in the grander scheme. Nobody seems to completely adhere to the rules. As a result, these small patterns never seem to lead to clean code.
I loved coding as a child and pursued CompSci in college. But having worked a few years in the industry, I really think I do not know how to solve anything. At one point I felt as if everyone is gaslighting me. But if multiple people from different companies say I need to learn, then I should.
Right now I want to read to know what exactly I am missing in my knowledge about how code works in large codebases
(Edit: Thanks for the reply!)