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
@mcsee
mcsee / published.dart
Created September 28, 2025 14:57
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
class Article {
final DateTime publishDate;
final String title;
final String content;
Article({
required this.publishDate,
required this.title,
required this.content,
});
@mcsee
mcsee / article.dart
Created September 28, 2025 14:56
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
class Article {
final DateTime date;
final String title;
final String content;
Article({
required this.date,
required this.title,
required this.content,
});
@mcsee
mcsee / api-using-header-versioning.php
Last active September 12, 2025 00:40
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?php
// Header-based API versioning example
// GET /api/primes?limit=12 HTTP/1.1
// Host: eratostenes.com
// Accept: application/vnd.myapi.v2+json
// NOTICE THE HEADER V2
$acceptHeader = $_SERVER['HTTP_ACCEPT'] ?? '';
@mcsee
mcsee / api-using-url-path-versioning.php
Last active September 11, 2025 12:59
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?php
// https://eratostenes.com/api/v2/primes?limit=10
// NOTICE /V2/
// Version 2 is faster!
$requestUri = $_SERVER['REQUEST_URI'];
if (preg_match('#^/v([0-9]+)/#', $requestUri, $matches)) {
$version = $matches[1];
} else {
@mcsee
mcsee / api-using-query-versioning.php
Last active September 11, 2025 12:59
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?php
// Misusing query parameters for versioning
// https://eratostenes.com/api/primes?limit=10&version=2
// Version 2 is faster!
$version = $_GET['version'] ?? '1';
if ($version === '1') {
echo json_encode(['data' => 'Response from API v1']);
@mcsee
mcsee / UserService.php
Created August 31, 2025 22:49
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?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)
@mcsee
mcsee / AnotatedUserService.php
Last active September 11, 2025 12:59
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?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");
}
}