Skip to content

Instantly share code, notes, and snippets.

View dario-l's full-sized avatar

Dariusz Lenartowicz dario-l

View GitHub Profile
@model UserViewModel
@using (Html.BeginForm())
{
<div>
@Html.HiddenFor(m => m.Id)
@Html.TextBoxFor(m => m.FirstName)
@Html.TextBoxFor(m => m.LastName)
@Html.DropDownListFor(m => m.CountryId, Model.Countries)

If you have two days to learn the very basics of modelling, Domain-Driven Design, CQRS and Event Sourcing, here's what you should do:

In the evenings read the [Domain-Driven Design Quickly Minibook]{http://www.infoq.com/minibooks/domain-driven-design-quickly}. During the day watch following great videos (in this order):

  1. Eric Evans' [What I've learned about DDD since the book]{http://www.infoq.com/presentations/ddd-eric-evans}
  2. Eric Evans' [Strategic Design - Responsibility Traps]{http://www.infoq.com/presentations/design-strategic-eric-evans}
  3. Udi Dahan's [Avoid a Failed SOA: Business & Autonomous Components to the Rescue]{http://www.infoq.com/presentations/SOA-Business-Autonomous-Components}
  4. Udi Dahan's [Command-Query Responsibility Segregation]{http://www.infoq.com/presentations/Command-Query-Responsibility-Segregation}
  5. Greg Young's [Unshackle Your Domain]{http://www.infoq.com/presentations/greg-young-unshackle-qcon08}
  6. Eric Evans' [Acknowledging CAP at the Root -- in the Domain Model]{ht
@dario-l
dario-l / PriceList
Last active August 29, 2015 14:02
PriceListDefinition mapping
<class xmlns="urn:nhibernate-mapping-2.2" lazy="true" schema="timetables" name="PriceList" table="PriceLists">
<id name="ID/>
<discriminator type="String">
<column name="discriminator" />
</discriminator>
<version name="Version">
<column name="Version" />
</version>
<property name="Number" type="System.Int32">
<column name="Number" not-null="true" />
using Microsoft.Win32;
...
RegistryKey masterKey = Registry.LocalMachine.CreateSubKey
("SOFTWARE\\Test\\Preferences");
if (masterKey == null)
{
Console.WriteLine ("Null Masterkey!");
}
else
public static class ModuleHandleExtensions
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public static object Handle<T>(
this NancyModule m,
Action<T> handle,
Func<T, object> successResult,
Func<T, object> failureResult = null)
{

Rough Notes about CQRS and ES

Once upon a time…

I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).

I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).

It seems inevitable to throw Domain Driven Design (DDD) in to the mix.

@dario-l
dario-l / Suteki.EventBus.js
Created May 13, 2016 17:01 — forked from mikehadlow/Suteki.EventBus.js
A simple javascript event bus
var Suteki = Suteki || {};
Suteki.new_eventBus = (function(){
var self = {};
var subscriptions = {};
var unsubscribeTokens = [];
var subscriptionPointers = [];
@dario-l
dario-l / GetEventStoreRepository.cs
Created April 7, 2017 11:00 — forked from jen20/GetEventStoreRepository.cs
Event Store implementation of the CommonDomain IRepository interface and integration tests
public class GetEventStoreRepository : IRepository
{
private const string EventClrTypeHeader = "EventClrTypeName";
private const string AggregateClrTypeHeader = "AggregateClrTypeName";
private const string CommitIdHeader = "CommitId";
private const int WritePageSize = 500;
private const int ReadPageSize = 500;
private readonly Func<Type, Guid, string> _aggregateIdToStreamName;
void Main()
{
var pushId = FirebasePushIDGenerator.GeneratePushID();
Console.WriteLine(pushId);
Console.WriteLine(FirebasePushIDGenerator.GeneratePushID());
Console.WriteLine(FirebasePushIDGenerator.GeneratePushID());
Thread.Sleep(5);
Console.WriteLine(FirebasePushIDGenerator.GeneratePushID());
Thread.Sleep(5);
Console.WriteLine(FirebasePushIDGenerator.GeneratePushID());
@dario-l
dario-l / Catch.cs
Created May 9, 2017 20:45 — forked from yreynhout/Catch.cs
Async Aggregate Source Command Handler Testing ... in a gist
using System;
using System.Threading.Tasks;
public static class Catch
{
public static async Task<Optional<Exception>> ExceptionAsync(Func<Task> action)
{
var result = Optional<Exception>.Empty;
try
{