PHP code smells

  • SumoMe

PHP code smells

I recently came across a YouTube video that explains in very good details what PHP code smells are. Now to fully understand what PHP code smells are you must know or understand what code smells are.

Code smell, as design patters do, serve the same purpose. They both empower developers to write better code by identifying possible points of failure and more importantly areas to improve. Knowing them is a must for every developer.

Identifying PHP code smells will definitely help the Magento community.

What is a code smell?

Wikipedia defines it as the following:

In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. Code smells are usually not bugs — they are not technically incorrect and don’t currently prevent the program from functioning. Instead, they indicate weaknesses in design that may be slowing down development or increasing the risk of bugs or failures in the future.
Often the deeper problem hinted by a code smell can be uncovered when the code is subjected to a short feedback cycle where it is refactored in small, controlled steps, and the resulting design is examined to see if there are any further code smells that indicate the need of more refactoring. From the point of view of a programmer charged with performing refactoring, code smells are heuristics to indicate when to refactor, and what specific refactoring techniques to use. Thus, a code smell is a driver for refactoring.

and more can be found here

Why is this important?

I am glad you ask… as you may have read above code smells represent potential problems in your code and just like design patterns are there to help you code better so is a great understanding of what code smells are.

You can see a great list of code smells here

So understanding code smells is a must for every php developer but more importantly is to apply this knowledge in creating better Magento code. After all we are Magento developers right?

So the main reason this video struck me so much is because I could recognize many situations where Magento’s extension could benefit from it.

Now without any more delays here it is:

VN:F [1.9.22_1171]
Rating: 8.4/10 (5 votes cast)
VN:F [1.9.22_1171]
Rating: +2 (from 2 votes)
PHP code smells, 8.4 out of 10 based on 5 ratings

Author: Luis Tineo

Husband, Father, performance improvement junkie, biker and video gamer, Linux user and in my day job I'm a Systems Architect at Blue Acorn.

Share This Post On