Skip to content

Instantly share code, notes, and snippets.

View rommsen's full-sized avatar

Roman Sachse rommsen

View GitHub Profile
let inline websocket<'Data> =
FunctionComponent.Of(fun (props: {| url : string; retryTimeSpan : TimeSpan; onConnected: bool -> unit; onMessage: 'Data -> unit |}) ->
let mutable currentlyConnected = false
let mutable wasAlreadyConnected = false
let connected = Hooks.useState false
let mutable webservice = null
let connect() =
if currentlyConnected then () else
let ws = WebSocket.Create(props.url)
@rommsen
rommsen / Attendee.cs
Last active February 26, 2020 18:40
Practical DDD Step 4 - Value Objects
using System;
using System.Collections.Generic;
namespace ddd_patterns
{
public class Attendee
{
private readonly Guid _id;
private readonly string _firstname;
private readonly string _surname;
@rommsen
rommsen / OnlineTickets.cs
Last active February 26, 2020 18:37
Practical DDD Step 1 - Refactoring to deeper insights
using System;
using System.Data;
using System.Data.SqlClient;
namespace ddd_patterns
{
public class OnlineTickets
{
private readonly string _connectionString;
@rommsen
rommsen / OnlineTickets.cs
Last active February 26, 2020 18:37
Practical DDD Step 2 - Repositories
using System;
using System.Data.SqlClient;
namespace ddd_patterns
{
public class OnlineTickets
{
private readonly string _connectionString;
public OnlineTickets(string connectionString)
@rommsen
rommsen / IPaymentService.cs
Last active February 26, 2020 18:36
Practical DDD Step 3 - Domain Services
namespace ddd_patterns
{
public interface IPaymentService
{
public bool Pay(decimal amount, decimal vat);
}
}
@rommsen
rommsen / IPaymentService.cs
Last active February 26, 2020 18:33
Practical DDD Step 4 - Domain Services
namespace ddd_patterns
{
public interface IPaymentService
{
public bool Pay(decimal amount, decimal vat);
}
}
@rommsen
rommsen / Step7_Attendee.cs
Created February 26, 2020 18:30
Practical DDD Step 5
using System;
using System.Collections.Generic;
namespace ddd_patterns.Step7
{
public class Attendee
{
private readonly Guid _id;
private readonly string _firstname;
private readonly string _surname;
@rommsen
rommsen / Step6_IPaymentService.cs
Created February 26, 2020 18:29
Practical DDD Step 4
namespace ddd_patterns.Step6
{
public interface IPaymentService
{
public bool Pay(decimal amount, decimal vat);
}
}
@rommsen
rommsen / AddressBook.cs
Last active February 25, 2020 09:21
Value Objects
namespace ddd_patterns
{
public class AddressBook
{
public readonly PhoneNumber HomeNumber;
public readonly PhoneNumber MobileNumber;
public readonly PhoneNumber WorkNumber;
public readonly ValidEmailAddress Email;
public AddressBook(PhoneNumber homeNumber, PhoneNumber mobileNumber, PhoneNumber workNumber, ValidEmailAddress email)
@rommsen
rommsen / Attendee.cs
Last active February 25, 2020 09:18
DomainServices
using System;
using System.Collections.Generic;
namespace ddd_patterns
{
public class Attendee
{
private readonly Guid _id;
private readonly string _firstname;
private readonly string _surname;