Refactoring WordPress

I like WordPress because it’s easy to install and use. But I really dislike the way it’s put up.

I’m not going into an exhaustive critic here because I really bend to the dedication coders devote to WordPress. I’ll just say what refactoring WordPress needs.

  1. the architecture must conform to a clean design, with the details hidden in lower layers, but with the mechanics shown in higher ones.
  2. For example, if you open the wordpress/index.php file this is what you find:

    <?php /* Short and sweet */ define('WP_USE_THEMES', true); require('./wp-blog-header.php'); ?>

    which is certainly short and weird for the main code of any software! We shoud see the famous loop here, shouldn’t we?

  3. the documentation must be organized like any other software documentation: A user guide + a developer guide + an API reference + an instant guide.
  4. For example, at this moment in the docs main page there are 114 content links in 8 categories.

  5. any given external name must get an expert approval, before it’s used for the first time. A name is to be considered external if it’s going to be used (or understood) by someone else, be they persons or software, outside the smallest scope where it appears for the first time.
  6. For example, digging in the code I found this function name: maybe_create_table (at wordpress /wp-admin /upgrade-functions.php :332). By its name I’d say that sometimes the function creates a table, and other times it does not. This is true with respect to the chosen implementation, which has been optimized for not creating a table if it already exists. But it’s false with respect to the context, because before executing the function, a table may exist or not, but after executing it, a table will exist for sure. So, maybe_create_table should be renamed as always_create_table, or just create_table. In case of collision with a previous create_table function, it could be named create_table_if_needed. And it’s generally a good idea to sort the words of a multi word name such that in a sorted list of similar objects, similar/related entries will appear near to each other.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.