Answer the question
In order to leave comments, you need to log in
How to learn to design programs in the OOP style?
I can't exactly formulate the question, but I need advice from experienced programmers.
I have been programming in PHP for several years now. I know the principles of OOP well. I read several books about design patterns. But at the same time, when I need to design a new system, I fall into some kind of stupor, as if I lack some one cherished knowledge. You start to think that you can write this way and that way - as a result, I sit and can’t decide what class composition to create. It seems that for others the code turns out to be expressive, logical, but for me what is not a class is a violation of all the principles of OOP and solid. The code as a whole comes out as if in procedural style.
Please recommend a book. Or how to properly design OOP-style applications?
Answer the question
In order to leave comments, you need to log in
Look towards Domain-Driven Design (DDD).
- https://habr.com/ru/post/269589/
- https://habr.com/ru/post/269893/
- https://habr.com/ru/post/267125/
Good books on this topic :
- Robert Martin "Clean Code Creation, Analysis and Refactoring"
- Robert Martin "Clean Architecture"
- Steve McConnell "Perfect Code"
If you can find sources of projects similar to yours, study them,
see how similar problems were solved there.
Another very good option is to find an experienced developer and ask him to review your code, so that he will explain to you how it is better to do it here, and how it could be done there and why it would be better this way.
You do not lack knowledge, but understanding and practice. the easiest option to start learning frameworks would be laminas / simphony, but phpixie / slimphp is enough for a start.
You need to refactor, rewrite. You see what can be improved - improve, redo.
I redid it and you see that it has become worse - roll back to the old version. And this is how you mold a candy out of clay.
With experience, there is a skill to immediately see the best options and alterations are no longer so global.
Maybe you just don't have enough experience yet. Since you have read books, you need to focus on practice.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question