Monday, May 6

Mending Code

Why you hate working with legacy code
Mending Code

Why you hate working with legacy code

Sometimes it is confusing "It's just a small change ..... " If you have worked with a client in the wild who needs a change to their existing codebase you will be familiar with this type of request.  On the surface this looks like it will be simple, but when you start digging into the code the crazy starts popping up.   Most custom code that has been written for small to mid-sized businesses suffers from a common set of problems. It was written under a deadline.It was written by one person and then updated by others with no consistent coding practices.It does not follow professional coding standards.There is little to no documentation or testing.Changes have been applied in a band aid fashion over time.It works (at least mostly) and it is in production. These prob...
Mending a PHP do…while(false)
Mending Code

Mending a PHP do…while(false)

Today's moment in code mending madness is brought to you by the "do...while loop" . Normally a "do .. while loop" is just that -- a loop. The do statement is executed while the while statement is false. This code starts off with the while statement being false meaning the code is only executed once. So what is even the point? My inner child is rethinking her life choices Working on legacy code is full of those WTF moments where you are staring at something and can't at first glance (or fifth or twentieth) understand what is going on. Here is a cleaned out version of the issue: $condition = ''; do{ if($condition == 'a'){ echo "this is the a thing<br>"; continue; // that is a little odd } if($condition == 'b'){ echo "this is the b thing <br>"; c...