interface Collaborator {
collaborate(): void;
}
This file contains 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
// 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)); | |
} |
This file contains 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
// From Fixing Object oriented abusers, Manh Phan https://ducmanhphan.github.io/2020-01-24-Fixing-object-oriented-abusers/ | |
class CheckoutHandlder { | |
// ... | |
convertToCurrency(price, currencyTo) { | |
if (currencyTo === "EUR") { | |
return price * 0.9; | |
} else if (currencyTo === "CAD") { | |
return price * 1.35; | |
} else { |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using NSubstitute; | |
using NSubstitute.Exceptions; | |
using Xunit;namespace KataTirePressureVariation.Test | |
{ | |
public class AlarmShould | |
{ | |
private Sensor sensor; | |
Notifier notifier; |
This file contains 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
using Xunit; | |
namespace Gilded_rose.Test | |
{ | |
public class GildedRoseTest | |
{ | |
private const int MinQuality = 0; | |
private const int MaxQuality = 50; | |
[Fact] |
This file contains 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
package com.gildedrose; | |
import static org.junit.jupiter.api.Assertions.assertEquals; | |
import org.junit.jupiter.api.Test; | |
public class GildedRoseTest { | |
private static final int MIN_QUALITY = 0; |
This file contains 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
// 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(); |
This file contains 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 Manager { | |
private employee: Employee; | |
constructor(employee: Employee) { | |
this.employee = employee; | |
} | |
doThing(): void { | |
this.employee.doThing(); | |
} |
This file contains 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
// As a direct chain of calls | |
class FlightBooking { | |
private plane: Plane; | |
constructor(plane: Plane) { | |
this.plane = plane; | |
} | |
// ... | |
isSeatAvailable(rowNumber: number, seat: string): boolean { |