73.4 F
Los Angeles
Thursday, September 28, 2023

ASUS Announces 2023 Vivobook Classic Series

On April 7, 2023, ASUS introduced five new models in the 2023 Vivobook Classic series of laptops. The top laptops in the series use the 13th Gen Intel® Core™...

Airman Arrested In Case of Leaked Classified Documents

Massachusetts Air National Guardsman Jack Teixeira has been arrested in the latest case of leaked classified documents. Teixeira, 21, is the head of Thug Shaker Central, an online gaming...

Microsoft OneNote to Gain Copilot

Microsoft 365 Copilot is coming to OneNote.
WebdesignWordPressSpacing WordPress Code Adds Readability and Improves Sharability

Spacing WordPress Code Adds Readability and Improves Sharability

Tom McFarlin recently wrote a beautiful piece suggesting two tips for writing WordPress code. A few commenters stated they were against spacing as described in the WordPress coding style. Others argued against the tip for writing WordPress code: filter, documentation, and function.

Spacing Improves Readability

The PHP code in a WordPress plugin is not just about the end results but should be written for the novice programmer wanting to learn from your work. This is why spacing may seem like a bad idea until you think about the novice who may read the code.

I’ve spent countless hours reading code written by others and can tell you spacing allows me to view the code easier. Sometimes I print out the code and mark it up with a pen and highlighter. It’s all about interacting with the code to try to dissect and understand why something is written a certain way.

Please consider this analogy: a writer would not put everything into one paragraph, right? Or more extreme, a writer would not crumple up a paper they’ve just authored because someone else may want to read the work. Maybe the point is that the PHP code is not just the result / return values but the code itself.

As a final plea, spacing your code helps others and that is the true spirit of Open Source.

Skip the IDE when Learning

Maybe you are considering the latest version of PHPStorm. This IDE (and many others) can ‘refactor’ your code – and space it out to meet the coding standards. This is a bad idea. Why? Sometimes spacing out can help you find an error before the problem becomes hidden.

Still I appreciate the time it takes to write clean code and have recently “scribbled” out ideas and later cleaned things up so I could evaluate the ideas. In fact, I recently found a problem in my reasoning in a block of code after I was adding space to step back and view the code.

These two reasons are why I spend hours going through past lines of code and seeing if there is a better way. Sometimes an error jumps out of the page.

What do you think? Should authors of WordPress plugins consider the novice programmer or only consider the end result of the plugin?

Layne Heinyhttp://www.layneheiny.com
LPH is a high school physics teacher interested in the Apple iPad and iPhone, Microsoft Surface, Tablet PCs, and other mobile devices. He resides with one large dog who begs for pizza, hamburgers, French fries, and anything else on the dinner table.

Latest news

Related news