8

I've only recently started making plugins and themes for WordPress. So far, I've been able to find most things by doing a google search, and getting the plugin to do what was intended has not been a problem.

My question is... If I have written my plugin in one way (say, I am using WPDB to make a SQL query) and I think there may be a better way to do it with the built-in WordPress functions, but I don't know which functions. Should I ask a question along those lines?

The plugin I've written works. It would be more a philosophical coding style question.

Thanks.

  • 4
    Have you already read How to Ask? Aside from that, it's not a philosophical question, but one about better practices, etc. Make sure it's not just about plain php and take a look at programmers.stackexchange.com as well to see if it fits there. – kaiser Sep 22 '16 at 22:17
  • That's great advice, thank you. I was asking specifically about WordPress but I should definitely look at my all-round coding too and have joined Programmers. "Better practices" must remember that phrase! – sdexp Sep 22 '16 at 22:39
  • Everything that has already been said here is great advice. As long as you're asking about best practice and not for opinions, then I'd say go ahead! Also, you can always ask about opinions in chat if you'd like :) – Tim Malone Sep 24 '16 at 4:52
10

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.

  • 2
    almost word to word with the answer I had in "draft" – Mark Kaplun Sep 23 '16 at 17:07
  • My question on here so far was asking about some debug errors I was getting. The debug errors weren't causing any problems other than I could see them with debug switched on. On the one hand it's a specific WordPress question because it's about WordPress AJAX, but on the other hand the thing that I was unable to see (how to define the AJAX variable) is technically just PHP, I suppose. Where you have 'something' => $variable I was trying to define 'something', as opposed to $variable. I got a -1 for my first question which made me feel sad but at least someone told me where I was going wrong. – sdexp Sep 24 '16 at 11:37
  • @sdexp my answer focus on the fact that from OP it seemed to me that you were considering anything that regards something that works is a philosophical question, which is not. – gmazzap Sep 25 '16 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .