There is a bunch of books that state principles about good code (SOLID, DRY, Design patterns etc.) Those principles are solutions to some problems. An application of those principles could go like that:
Approach 1: I know the principles ⇒ I will write code that respect those principles.
The problem with this approach is that principles are context-related. We need to make sure that we have the problem (the context) for which we apply the solution. A preferable approach is:
Approach 2: I write simple code ⇒ Using some tools, methods I can discover that I have some problem ⇒ Apply the principle related to that problem.
So, is there some tools, methods etc. to use to figure out the problems. An example would be, using git, I notice that there is a class that depends on a less stable class. I then decide to introduce an interface and do a dependency inversion. I would appreciate any ressources that can help (books, videos, courses, papers etc.).