I've been coding in python for about 6 years now. I am proficient enough to understand a good amount of the language features. When I look into source code for a number of libraries such as pandas
or requests
I'm able to understand a good deal of what is going on.
I've worked with python long enough to develop a real feeling for object oriented programming. I understand key concepts like inheritance, composition and aggregation. I recently learned more about type hinting so that I can statically check my code and be more aware of the types that are flowing through my program.
Over the years, I've also developed a bit of an obsession with design patterns. I bought the GoF book which I consult regularly. I also study the code on websites such as refactoring.guru or sourcemaking to try to get a better grasp on OOP and truly implement this in my code.
Unfortunately, aside from minimal/academic examples concocted for educational purposes, I have never really been able to build truly object oriented code in a production setting. Every time I try, my code gets way too complex, and I end up falling back on more simple patterns like functions. Don't get me wrong, I know that classes are useful in programming, but I just fail to make use of them such that they make my life easier. In contrast, I can see the use of higher order functions, so I use those sometimes to great effect.
I feel like there must be some sort of middle ground between the two extremes:
- Understanding the basic building blocks of OOP ((multiple) inheritance, composition, aggregation, nominal/structural subtyping, the diamond problem)
- Understanding full-blown design patterns and patterns of patterns (such as MVC)
I doubt that even experienced programmers decide what design pattern they want to use before they start coding. I feel like they probably start coding and use a couple of key concepts to organize code into classes as they go. What am I missing to start incorporating classes into my work such that they can help, rather than hamper me? What is the middle ground?