There was a time when i thought you needed to use patterns and best practices to keep consistent and maintainable code. After all if everyone follows them then we are all building software in a similar way. New and existing team members and freelancers can all understand the code and maintain it. Problem solved, blog post over.
However do you end up forcing a pattern into an architecture for the sake of it? This could lead you to not build the best solution for the problem, but the solution with the best use of several patterns. Could your code be simpler and more maintainable without using the patterns?
Best practice treated like a magic bullet.
By applying “best practices” you limit the chances of failing from a certain point of view, but does it stop you thinking and using your brain? One of the many things I learnt working with @grumpydev was that if you use common sense and engage your brain then your code will more than likely be maintainable and others will understand what you are trying to achieve. Also when you come back to that code that you haven’t seen for months does applying common sense and engaging your brain mean you understand your own code easily.
Principles over patterns.
Patterns can be useful, but it depends on context. Just because the pattern worked in one instance does not mean it will always work for the code you are writing. Principles however should when applied well, assist you in writing quality code. My wife bakes cakes as one of many jobs she does (shameless plug – @itcakestwobaby) and started out using a recipe for cupcakes. It describes everything you need to do to make cupcakes just like her. Does this mean anyone can make them like her? Maybe…however I have watched her and she doesn’t stick to the recipe, it is all her own judgement from experience and knowing her ingredients and our oven. I don’t think you can add a spoonful of factory pattern and a dash of decorator pattern and create a perfect solution by keeping to them.