Skip to content

Instantly share code, notes, and snippets.

// 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));
}
// 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 {
using System;
using System.Collections.Generic;
using NSubstitute;
using NSubstitute.Exceptions;
using Xunit;namespace KataTirePressureVariation.Test
{
public class AlarmShould
{
private Sensor sensor;
Notifier notifier;
@trikitrok
trikitrok / GildedRoseTest.cs
Created June 28, 2023 12:24
with surviving mutants
using Xunit;
namespace Gilded_rose.Test
{
public class GildedRoseTest
{
private const int MinQuality = 0;
private const int MaxQuality = 50;
[Fact]
@trikitrok
trikitrok / GildedRoseTest.java
Created June 28, 2023 12:21
with surviving mutants
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;

Mars Rover movement

Description

In this exercise we'll implement from scratch part of the Mars Rover kata.

The rover interface would have only one method: receive(commands: string): void

This is a summary of the behavior of the rover that we'll implement:

// 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();
class Manager {
private employee: Employee;
constructor(employee: Employee) {
this.employee = employee;
}
doThing(): void {
this.employee.doThing();
}
// As a direct chain of calls
class FlightBooking {
private plane: Plane;
constructor(plane: Plane) {
this.plane = plane;
}
// ...
isSeatAvailable(rowNumber: number, seat: string): boolean {