I’ve started reading a book on design patterns which has made me wonder what kind of questions to ask when thinking about structuring one’s code. Recently I started to migrate the Learnclick code from CodeIgniter to Laravel (at the moment just for practice purposes). While thinking about design patterns etc, I realized that I could easily get paralyzed by the process of thinking about how to write the most maintainable and clean code.
I decided to start somewhere and then start refactoring as I don’t want methods to become too big. This then automatically led to the question, what classes to create and if I should use inheritance or composition. One thing that stuck out for me when looking at design patterns was that one should always try to create an interface for things that have different implementations but work similar. Interfaces are an important concept of object oriented design. Then we can start thinking about design patterns, but they should be more of a guideline rather then an exact way of doing things, like this article helpfully explains.
There is still a lot to learn, but I think the new way I’ve designed the Learnclick part for generating different types of questions is already a lot better than what I did before when I used a more procedural programming style. My issue in the past used to be that although I understood the principals of object oriented design, I couldn’t transfer the examples of cats & dogs to more abstract ideas.
How do you go about designing your software code? Please leave a comment.
Top comments (0)