Skip to content

Instantly share code, notes, and snippets.

@ralfw
ralfw / layered.cs
Last active July 22, 2022 07:14
Layered design vs stratified design
using System;
using System.Linq;
namespace layered
{
class MainClass
{
public static void Main(string[] args) {
var data = new DataLayer();
var business = new BusinessLayer(data);
@ralfw
ralfw / pipelineOf.cs
Last active January 5, 2021 22:01
Pipes and filters à la Steve Bate - but with a twist :-) Not just classes are filters, but also objects and functions.
public class PipelineOf<T> : IFilterOf<T>
{
public class Result
{
public static Result Success(T value)
{
return new Result {IsSuccess = true, Value = value};
}
public static Result Failure(Exception exception)
@ralfw
ralfw / textmanager.cs
Last active May 30, 2020 08:09
Text Obfuscation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace ancientcode {
public class TextManager {
private TextManagerHelper hlp = new TextManagerHelper();
private Random rnd = new Random();
@ralfw
ralfw / akii.cs
Created December 15, 2019 12:11
ES Challenge - Bowling Game Kata Submissions
class RollMade {
public int Pins;
}
@ralfw
ralfw / 01 bowling game.cs
Last active December 10, 2019 09:33
EventSourcing Challenge: Bowling Game Kata
using System.Linq;
using System.Collections.Generic;
class BowlingGameBareBones
{
#region Event definitions
abstract class Event {}
class Rolled : Event {
public uint Pins;
@ralfw
ralfw / 00 eventstore.cs
Last active November 27, 2019 16:27
DDC 2019 - Event-Orientation Workshop
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Newtonsoft.Json; // NuGet package dependency
namespace eventorientation
{
@ralfw
ralfw / Experimenter.cs
Last active July 25, 2019 09:57
Experimenter: Reduce noise in code by pushing try-catch into the background
public static class Experimenter
{
private static ILogging __log;
public static void Init(ILogging log) => __log = log;
public static bool Try(string logMsg, Action experiment)
{
try
{
@ralfw
ralfw / ocr1.txt
Last active July 2, 2019 08:31
Bank OCR Test Data
_ _ _ _ _ _ _
| _| _||_||_ |_ ||_||_|
||_ _| | _||_| ||_| _|
_ _ _ _ _ _ _
|_||_|| || ||_ | | ||_
| _||_||_||_| | | | _|
@ralfw
ralfw / game.cs
Last active October 8, 2018 09:10
IODA Architecture for Bowling Game Kata
public class Game {
private int[] rolls = new int[21];
private int currentRoll = 0;
public void roll(int pins) {
rolls[currentRoll++] = pins;
}
public int score() {
var frames = Detect_frames (rolls);
@ralfw
ralfw / Dockerfile
Created August 18, 2016 06:31
Roll your own Elm Docker container
# Build image with Node.js, Elm and Nginx
FROM debian:latest
# prepare
RUN apt-get -y update
RUN apt-get -y install apt-utils
# install curl, http://stackoverflow.com/questions/27273412/cannot-install-packages-inside-docker-ubuntu-image
RUN apt-get -y install curl