On the one hand, I'm learning so much about how to write clean code; while on the other, I inherited a complete mess. At the same time, I'm working on another legacy code base that was the number one mess. If anything, this juxtaposition is reinforcing the lessons I'm entrenching myself in.
Let this example suffice to illustrate the mess I'm washing through:
if(($_GET['job'] == 'placeorder') || ($_GET['job'] == 'cancelorder'))
$form .= '<div '.lookup_data($data, get_user(...),...,).' class="'.get_class_for_job($_GET['job']).'"'.....more form stuff....
$tmp_result = $db.mysqli_query('select '.$tbl_order_columns_array.explode().' from tbl_orders where '.check_for_id($_GET['order_id']....db result handling to follow
The whole program is like a run-on sentence with the structure being dictated by the layout of the page. There are some base helper functions that do some work. However, the generic nature of those interfaces make for too much logic for them to be easily understood. I'm encountering if statements that are hundreds of lines long followed by an else or perhaps elseifs; nested ifs on the order of five or more; loops that contain hundreds of lines of code. The bottom line is that all of this makes for really poor readability. When code is difficult to read, it is difficult to comprehend. When it is difficult to comprehend, it is difficult to support. When it is difficult to support, service level declines, defect rates go up, support eats up more time which means less time to spend on other commitments, which means defect rates go up... Enter the viscous cycle!