Skip to content

Instantly share code, notes, and snippets.

class Manager {
constructor(employee) {
this.employee = employee;
}
doThing() {
this.employee.doThing();
}
doAnotherThing() {
// From Ayush Jindal's exercises for code smells https://github.com/ayjindal/CodeSmells
class Customer {
constructor(name, address) {
this.name = name;
this.currentAddress = address;
}
printAddress() {
console.log(
// From Rachel M. Carmena's https://github.com/rachelcarmena/code-smells
class CoolStack<T> extends Array {
push(...items: T[]): number {
return super.push(...items);
}
public pop(): T {
return super.pop();
// From Rachel M. Carmena's https://github.com/rachelcarmena/code-smells
class DistanceCalculator {
betweenPoints(x1, y1, x2, y2) {
return Math.sqrt(Math.pow((y2 - y1), 2) + Math.pow(x2 - x1, 2));
}
toOriginFrom(x, y) {
return Math.sqrt(Math.pow(y, 2) + Math.pow(x, 2));
}
@trikitrok
trikitrok / embedded_c_testing_tdd_resources.md
Created December 20, 2016 08:37
Resources for embedded C testing and TDD
// As a direct chain of calls
class FlightBooking {
private Plane plane;
// ...
public boolean isSeatAvailable(int rowNumber, String seat) {
return plane.getRows().get(rowNumber - 1).isAvailable(seat);
}
}
// Chaining calls through intermediate results
using System;
using System.Collections.Generic;
using NSubstitute;
using NSubstitute.Exceptions;
using Xunit;namespace KataTirePressureVariation.Test
{
public class AlarmShould
{
private Sensor sensor;
Notifier notifier;
// Adapted from Rachel M. Carmena's https://github.com/rachelcarmena/code-smells
<?php
class DistanceCalculator {
public function betweenPoints(int $x1, int $y1, int $x2, int $y2) : float {
return sqrt(pow(($y2 - $y1), 2) + pow($x2 - $x1, 2));
}
public function toOriginFrom(int $x, int $y) : float {
<?php
class Manager {
Worker $worker;
// some functions
public function doThing() : void {
$this->worker->doThing();
}