This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UserService { | |
// Step 1: Identified annotations | |
// (@author, @version, @description, | |
// Step 2: Evaluated their purpose | |
// (metadata, deprecated, todo notes) | |
// Step 3: Removed unnecessary annotations (no value added) | |
// Step 4: Replaced critical annotations | |
// with explicit code (none needed) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @author John Wick | |
// @version 3.14 | |
// @description Service for user operations | |
class UserService { | |
/** | |
* @deprecated | |
* @param int $id | |
* @return string | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User { | |
public email; | |
private name; | |
// Step 1: Choose consistent indentation (2 spaces) | |
// Step 4: Public methods before private ones | |
constructor(name, email) { | |
this.name = name; | |
this.email = email; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User{ | |
private name; | |
public email; | |
constructor(name,email) { | |
this.name=name; | |
this.email = email; | |
} | |
private validateEmail() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface QueryResult { | |
void display(); | |
} | |
class SelectResult implements QueryResult { | |
public void display() { | |
System.out.println("Fetched rows"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DatabaseConnection { | |
public Object execute(String sql) { | |
if (sql.startsWith("SELECT")) { | |
return new ResultSet(); | |
} else if (sql.startsWith("INSERT")) { | |
return Integer.valueOf(42); | |
} else if (sql.startsWith("UPDATE")) { | |
return Boolean.TRUE; | |
} | |
return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processPayment(paymentData) { | |
try { | |
validatePayment(paymentData); | |
// This catch is specific to payment validation | |
} catch (error) { | |
// 1. Identify all generic error messages in your codebase | |
// that use terms like "Oops", "Something went wrong", | |
// or "An error occurred" | |
// 2. Replace generic messages | |
// with specific descriptions of what happened |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processPayment(paymentData) { | |
try { | |
// Too broad try catch | |
validatePayment(paymentData); | |
chargeCard(paymentData); | |
sendConfirmation(paymentData.email); | |
} catch (error) { | |
// Generic error message shown to user | |
return { | |
success: false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Auto { | |
constructor(motor) { | |
this.motor = motor | |
} | |
// 1. Identify methods that receive owned attributes | |
startEngine() { | |
// 2. Remove those parameters from the method signature | |
// 4. Rename the method if needed to match the new intention | |
this.motor.ignite() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Auto { | |
constructor(motor) { | |
this.motor = motor | |
} | |
startEngine(motor) { | |
motor.ignite() | |
} | |
} |
NewerOlder