Biggest mistake PHP coders make?

Not knowing what they are coding.

An example from a current project, the developers had to get all category ID's from a table with a parent-child structure for a given parent category. Including at times the top category.

They had chosen to write a query with multiple joins for each nested level and then they did a foreach and checked whether each of the joined ID's existed in the answer array and if not added it end up with a unique list of ID's.

This is a 1 grain of rice on a chessboard deal. 5 levels so first category has to be checked 5 times against an array of 1 element. But 10.000 category has to be checked 5x10000 if it is new. That is a LOT of checks. Very simple very fast ones but a LOT of them and that takes time. With 30k categories 3.5 seconds.

And they use the found categories to construct a query (IN()) with a select * and then request a row count for the count and then do ALL of it again to do the final query...

The code "works" it is perfectly legit. But it is also clear that the person who wrote it, doesn't get what he wrote. Doesn't get what is happening. Doing the same work twice is not just lazy, it shows you don't get what you are doing.

I have seen lots of mistake but the worst is just that, people trying to code who are just not getting it. I seen really poor code before by people who really just can't code and that is okay because their ineptitude usually stops them from messing it up to bad.

But this code in question is used in production and the company needs to grow and it can't because they company that produced it just can't hack it anymore.

There is a level where just using a subset of PHP and general server tech is okay and that is one of PHP's strengths but a LOT of actual developers stumble when they have to move past it and produce sites that can scale, can be updated and extended without each time hacking together a new approach (this code has 5 different entry points for the same frontend as each time they cobbled in a new "routing" page for the next feature.

To recap? Stagnation, developers who don't grow their skills and after years in the trade still write procedural code like it was 1999.

/r/PHP Thread