Does WordPress Code Really a Mess? - (r)
-language-notice>
The author wrote:
My displeasure with WordPress is not a hidden fact. I find it a messy code base and would suggest anyone with a expertise in technology against employing it.
Are you in a dire situation? Are the WordPress primary code so atrocious that you should avoid it altogether and choose something else for your project? In this piece, I'll look into this issue, and try to provide some light on the issue.
- What is Bad Code?
- Coders Aren't Important
- Users Don't Care
- Coders Don't Get Affected
- Can You write good code?
What exactly is Bad Code?
I think the fundamental issue is that noone really says what bad and messy code. On paper, something like "messy code" seems like a terrible idea however, does the average person know what it signifies? In addition, do they even care?
As always, there is a little more to it beyond the. There are some characteristics that can render code "bad", here are a few of them:
- Unoptimized code which performs slowly when compared with optimized code
- The mixing of different coding styles in a project
- Spaghetti code that can only be comprehended by the writer
- Unextendable that doesn't play nice with others
WordPress is indeed guilty of one and a half of these. The coding style is all over the place, that's for sure. Function names are inconsistent, certain modules employ an object oriented approach, some modules use procedural code, some files do not follow WordPress' own style guide and a couple of issues.
It's a sign that WordPress utilizes spaghetti code in a small amount, but apart from being annoying it's not an issue since thousands upon thousands understand it because it's a popular product.
What is the problem? Is WordPress badly developed? It is, but in the same way as the International Space Station uses terrible laptops. Both are true but there's a bit more going on behind the scenes.
But the real question is: what is the significance of this?
Coders aren't important.
As programmers we have to keep in mind that WordPress - at the end of the day, is a tool for users, not for us. You may think that spending 100+ hours working on an assignment isn't a lot, however, the person using your product could be spending eight hours per day with the platform, which is 3,000+ hours a year. That's just when your website is utilized by just one user.
People Don't Mind
Coder's Aren't Affected
A majority of users who work with WordPress do not have any issues with the issue at the very least, don't need to be. There's no scenario in which you'd need to alter the core code of a project. So, you will never be impacted by the messiness of the code base at none.
The only argument coders could have against WordPress is that it doesn't follow an MVC (model-view-controller) architecture. This is a completely legitimate criticism, however it's not like MVC is the only way to write clean code.
Actually, it is possible to make use of an method of object-oriented programming in plugins. You can even use and MVC-like structure if you prefer. However, the real issue is themes built in a way that you cannot simply inject MVC principles.
However, they adhere to strict rules and are well structured and well-organized, even though they're not MVC. This boils down to a common vein in every theme which makes it easy to work with them If you're aware of the basics of what you're doing.
Does it make sense to write Good Code?
The question isn't whether WordPress core code is either good or not. WordPress main code is kind chaotic, but it's still an excellent code. However, this doesn't mean that it cannot be vastly improved but in the context the purpose it serves, it's great.
It is important to emphasize that OOP isn't a panacea. If you are using simple plugins, a well defined procedure may make a great deal more clear.
Themes often mix presentation with the logic of things, which is an unwise practice. The guidelines on themes are written and with organizing, it is possible to are able to write a logical and simple theme.
With the advent of WordPress API any other critiques are thrown down the drain since you are able to use the data in the database anywhere. It is possible to use Laravel for everything and draw in data through the WordPress API.
Summary
At the end of the day, is WordPress codes is a mess? Sure, a portion of it does. Certain themes and plugins aren't perfect and can harm the community as total. As with any other program, WordPress isn't perfect. Like any other program I am of the opinion that WordPress is not the right tool to use for everything.
But, not using WordPress due to "the code is messy" is simply put the most foolish and uninformed reason. While the core code may be chaos, it's also quick and safe. Any code written on top of that to enhance the functionality can be well written.
Daniel Pataki
Hello, my name is Daniel, I'm the CTO here at . You may know me from Smashing Magazine, WPMU Dev, Tuts+ and other WordPress/Development magazines. Aside from WordPress as well as PHP I spend the majority of my time with Node, React, GraphQL and other technologies in the Javascript area.
While I'm not working on the most efficient hosting system within the Universe I like to play games for the table, play football in the office as well as travel. I also play the guitar and sing in a pretty bad band.