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 / point.c
Last active July 15, 2020 23:54
Struct Point in C
struct Point {
float x;
float y;
}
@mcsee
mcsee / PolarPoint.c
Created July 15, 2020 23:53
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
struct Point {
float angle;
float distance;
}
@mcsee
mcsee / CartersianPoint.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
final class Point {
private $x;
private $y;
}
@mcsee
mcsee / PolarPoint.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
final class Point {
private $angle;
private $distance;
}
@mcsee
mcsee / PointFunctionsCartesian.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
final class Point {
private $x;
private $y;
public function x() {
return $this->x;
}
@mcsee
mcsee / PointFunctionsPolar.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
final class Point {
private $angle;
private $distance;
public function x() {
return $this->distance * cos($this->angle);
}
@mcsee
mcsee / Polygon.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
final class Polygon {
public $vertices;
}
@mcsee
mcsee / PolygonSettersAndGetters.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
final class Polygon {
private $vertices;
public function getVertices(): Collection {
return $this->vertices;
}
public function setVertices(Collection $newVertices) {
@mcsee
mcsee / PolygonWithVerticesRestriction.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
final class Polygon {
private $vertices;
private function __construct(Collection $newVertices) {
if (count($newVertices < 3)) {
throw new
Exception(
@mcsee
mcsee / PolygonSetterViolation.php
Last active February 20, 2025 22:34
This gist belongs to Clean Code Cookbook http://cleancodecookbook.com By Maximiliano Contieri http://maximilianocontieri.com
<?
$triangle =
new Polygon([new Point(1, 1), new Point(2, 2), new Point(3, 3)]);
$triangle->setVertices([new Point(1, 1)]);