Skip to content

Instantly share code, notes, and snippets.

View mcsee's full-sized avatar
🏠
Working from home

mcsee mcsee

🏠
Working from home
View GitHub Profile
<?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)
<?php
// @author John Wick
// @version 3.14
// @description Service for user operations
class UserService {
/**
* @deprecated
* @param int $id
* @return string
*/
@mcsee
mcsee / styled.js
Last active August 24, 2025 02:08
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
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;
}
@mcsee
mcsee / notstyled.js
Last active August 24, 2025 02:08
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
class User{
private name;
public email;
constructor(name,email) {
this.name=name;
this.email = email;
}
private validateEmail() {
@mcsee
mcsee / PolymorphicDatabaseConnection.java
Last active August 16, 2025 02:03
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
interface QueryResult {
void display();
}
class SelectResult implements QueryResult {
public void display() {
System.out.println("Fetched rows");
}
}
@mcsee
mcsee / DatabaseConnection.java
Last active August 16, 2025 02:02
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
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;
@mcsee
mcsee / user-service-handling.js
Last active August 10, 2025 10:30
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
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
@mcsee
mcsee / user-service-not-handling.js
Last active August 10, 2025 10:30
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
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,
@mcsee
mcsee / inline.js
Last active July 10, 2025 23:58
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
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()
@mcsee
mcsee / auto.js
Last active July 10, 2025 22:17
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
class Auto {
constructor(motor) {
this.motor = motor
}
startEngine(motor) {
motor.ignite()
}
}