Hi there! For around 3-4 years, I have been involved in PHP programming, specifically focusing on the Laravel framework. During this time, I have gained knowledge in various areas such as controllers, REST routes, ORM models, as well as familiarizing myself with tools like GIT and Composer.
However, I have come to realize that I still lack a fundamental understanding of programming concepts. It's a feeling that's hard to put into words.
That being said, I would greatly appreciate any suggestions or recommendations you may have to help me grasp the core principles of object-oriented programming (OOP). I am particularly interested in developing a better understanding of object-oriented thinking and the practical implementation of design patterns.
As an example, although I have learned how to utilize Dependency Injection in the constructor of a controller, I struggle to comprehend its inner workings and the reasons behind its usage.
I humbly ask for your assistance! If anyone can provide guidance or resources to aid me in my quest for knowledge, I would be incredibly grateful.
Thank you in advance for your valuable advice and for taking the time to help me out.
Here are a few recommendations to help you grasp these concepts:
1. Books: Consider reading books that focus on OOP and design patterns. Some recommended titles are "Clean Code" by Robert C. Martin, "Head First Design Patterns" by Eric Freeman and Elisabeth Robson, and "Refactoring" by Martin Fowler.
2. Online Courses: Enroll in online courses that specifically cover OOP and design patterns. Websites like Udemy, Coursera, and Pluralsight offer a wide range of programming courses taught by experienced instructors.
3. Practice: Apply the knowledge you gain by working on real-world projects or building personal projects that engage with OOP principles. The more you practice, the better you'll understand the concepts.
4. Join Developer Communities: Participate in developer communities like forums or Slack groups focused on PHP or Laravel. Engage in discussions and seek advice from more experienced developers who can guide you in understanding OOP concepts.
5. Code Reviews: Seek code reviews from other developers. This will provide valuable feedback and insights into improving your code, making it more aligned with OOP principles.
6. Open Source Projects: Contribute to open-source projects. This will expose you to different coding styles, architectural patterns, and collaborative development practices.
Here are a few more suggestions to help you deepen your understanding of object-oriented programming (OOP):
1. Design Principles: Study and understand important design principles like SOLID (Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion). These principles provide guidelines for writing maintainable, flexible, and modular code.
2. Practice Refactoring: Refactoring is the process of improving existing code without changing its behavior. Practice refactoring your own code or review and refactor existing codebases. This will help you apply OOP principles and improve the quality of your code.
3. Design Patterns: Dive deeper into design patterns, which are proven solutions to common problems in software design. Some popular design patterns include the Factory pattern, Singleton pattern, Observer pattern, and many more. Understanding their use cases and implementation can enhance your object-oriented thinking.
4. Attend Workshops and Conferences: Look out for workshops or conferences focused on PHP, Laravel, or software development in general. These events often have sessions dedicated to OOP and design patterns, where you can learn from industry experts and gain practical insights.
5. Collaborate and Pair Program: Find opportunities to collaborate with other developers or engage in pair programming sessions. Working alongside experienced programmers can expose you to different coding styles and help you learn new techniques.
6. Follow Blogs and Podcasts: Stay updated with the latest trends and best practices in PHP and OOP by following relevant programming blogs and podcasts. They often provide insightful articles, interviews, and discussions about OOP concepts and implementation.
few more suggestions to further enhance your understanding of object-oriented programming (OOP):
1. Take Advantage of Online Resources: Explore online platforms such as YouTube, Medium, and Dev.to for tutorials, articles, and video courses on OOP. Many experienced developers share their knowledge and insights through these channels.
2. Work with Design Patterns in Real Projects: Apply design patterns in real-world scenarios and projects. Implementing them practically will help you understand their benefits, trade-offs, and how they solve common software development problems.
3. Join Online Coding Communities: Engage in online coding communities such as Stack Overflow or GitHub. Participate in discussions, ask questions, and contribute to open-source projects. These interactions can provide valuable insights and feedback from the developer community.
4. Understand Language-specific OOP Concepts: Dive deeper into PHP's specific implementation of OOP concepts. Familiarize yourself with advanced topics such as interfaces, abstract classes, traits, namespaces, and autoloading. Understanding these language-specific features will enhance your grasp of OOP principles.
5. Explore Other Programming Languages: Consider exploring other programming languages that embrace OOP, such as Java or Python. Comparing different languages' implementations of OOP can give you a broader perspective on its concepts and help reinforce your understanding.
6. Build Personal Projects: Create personal projects that challenge you to apply OOP principles and design patterns effectively. Building practical applications will provide hands-on experience and foster a deeper understanding of how OOP translates into real-world scenarios.
Remember, mastering OOP is an ongoing process that requires continuous learning and practice. Keep a growth mindset, always seek new challenges, and be open to learning from both successes and failures. Good luck on your journey of deepening your understanding of OOP!
On my own behalf, I would like to mention that the only way to comprehend patterns is by confronting the problems they solve. Patterns are essentially solutions for specific problems (and their prevention). Therefore, it can be concluded that without problems, there are no solutions (though one might not realize their existence since the project may progress slowly, often involving edits or the addition of new functionalities unrelated to the previous ones).
I have spent a significant amount of time trying to understand patterns, reading all the recommended books, yet it seems that although I grasp the concept, its practical application remains elusive. It is clear in theory, but its real-life utilization is uncertain. In general, as I previously mentioned, one requires authentic challenges in order to refer to a book offering solutions, and then choose an appropriate course of action. This is similar to cooking: while you can attempt to prepare a dish on your own, there is no guarantee it will turn out delicious. However, if you consult a cookbook with proven recipes and follow them step-by-step, relying on the ingredients you possess, success becomes more likely.
With that said, I recommend two options for studying patterns:
1) Engage in challenging projects, genuinely complex ones, not just CMS sites. Over time, you will encounter problems. At that point, consulting pattern resources becomes natural, without requiring an in-depth understanding of each pattern. Instead, you intuitively recognize their relevance. It's akin to using an IDE instead of a code editor. For instance, I recall the moment I used Sablame and knew about the IDE's existence, but since I was working on simple tasks at the time, I couldn't grasp why I should use it when Sablame was sufficient. However, the need eventually arose to tackle more complex tasks, surpassing Sablame's capabilities. That's when I switched to the IDE, realizing that it had everything I needed. Moments like these make you wonder why you didn't utilize it earlier. The truth is, it wasn't necessary before. This might not be the best analogy, but I hope you get the idea. Of course, this approach is not entirely realistic since finding genuinely complex projects and joining a competent team can be challenging, as large projects are often poorly implemented. Nevertheless, consider creating your own CMS and incorporating as many patterns as possible.
2) Dedicate time solely to studying patterns (as I did). However, don't just read about them; instead, come up with a multitude of problems for each pattern, ones you have encountered or may encounter in the future. Often, patterns are described metaphorically, making them too abstract. Therefore, it becomes essential to devise specific tasks where you can apply these patterns. The second stage involves implementing these tasks, essentially translating theory into practice, multiple times with different problems.
In addition, I encourage you to have a clear understanding of UML diagrams. Using these diagrams as a reference will help refresh your memory about patterns without needing to read through examples. Simply looking at the diagram will remind you why a pattern is necessary and how it can be implemented.
That concludes my suggestions.
I became interested in OOP when I was coding a program in a procedural style and realized that I couldn't understand the code I had written the day before. After spending 12 hours refactoring, the code became more readable, resembling English rather than a jumble of characters, dots, numbers, and parentheses. To truly grasp OOP, it is best to work on a practical task using a pure language, without relying on frameworks.
Speaking of PHP, try creating your own ORM. Start with a simple query builder for CRUD operations, but make it versatile. This project will help you solidify your understanding of inheritance.
Currently, I haven't come across a comprehensive course on design patterns, but don't overestimate their importance. It's better to read or watch a video about SOLID principles, which are fundamental concepts in software development.
Once you have a clear understanding of inheritance and its purpose, then you can delve into design patterns. Personally, I find the Singleton pattern to be the most intriguing, while the others are just variations of applying inheritance and appear quite straightforward.