Philosophy doesn't break code. So everything that can potentially break code is not really philosophy.
To write something that "works", is just a tiny part of a developer job. A more bigger part is to make sure that it continues to work, that is possible to adapt it if underlying technology changes, but mostly important that brings value.
To bring value is the only aim of software.
For example, if you write a script that automates something that needs one minute a day to be done manually, but the automation script takes 3 months to be coded, even if at the end "it works" it is not providing value, it is a cost. And to that cost you have to add the cost of maintenance.
Understanding the difference between a code that works and a code that brings value is not philosophy, it is a non trivial part of our job. And there are no general rules, because how to bring value depends on the context and context easily changes.
Our best tool to understand how something should be done to bring value (and not only to work) is expertise.
If you ask here for expertise and not for opinions, provide specific context and possibly prior research effort, your question will be always be welcome here.
Of course, this website is specific to WordPress so we will accept questions that are related to WordPress, but in the SE network there are other websites like Programmers (as @kaiser suggested) where "generic" code questions are totally fine.