Antipattern: Making Bricks Without Straw
Let's discuss the bad habits that lead to the See No Evil antipattern.
We'll cover the following
Developers commonly practice the See No Evil antipattern in two forms: first, ignoring the return values of a database API, and second, reading fragments of SQL code interspersed with application code. In both cases, developers fail to use information that is readily available to them.
Diagnoses without diagnostics
Let’s take a look at the code below:
<?php
$pdo = new PDO("mysql:dbname=test;host=db.example.com",
"dbuser", "dbpassword");
$sql = "SELECT bug_id, summary, date_reported FROM Bugs
WHERE assigned_to = ? AND status = ?"; //1
$stmt = $dbh->prepare($sql); //2
$stmt->execute(array(1, "OPEN")); //3
$bug = $stmt->fetch(); //4
?>
Get hands-on with 1400+ tech skills courses.