Skip to content

Instantly share code, notes, and snippets.

View jaymecd's full-sized avatar

Nikolai Zujev jaymecd

View GitHub Profile
@jaymecd
jaymecd / cqrs.md
Last active August 29, 2015 14:14

CQRS - Command Query Responsibility Segregation

Split reads and writes on a architectural level.

It's based on CQS (Command Query Separation) as described by Bertrand Meyer. A method either reads state or mutates state, but not both.

CQRS was discovered by Greg Young.

CQRS enables rich domain models, which are not anaemic.

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.

The differences between a domain service and an application services are subtle but critical:

  • Domain services are very granular where as application services are a facade purposed with providing an API.
  • Domain services contain domain logic that can’t naturally be placed in an entity or value object whereas application services orchestrate the execution of domain logic and don’t themselves implement any domain logic.
  • Domain service methods can have other domain elements as operands and return values whereas application services operate upon trivial operands such as identity values and primitive data structures.
  • Application services declare dependencies on infrastructural services required to execute domain logic.
  • Command handlers are a flavor of application services which focus on handling a single command typically in a CQRS architecture.

Source: http://gorodinski.com/blog/2012/04/14/services-in-domain-driven-design-ddd/

1. Your application consists of three parts. Information always flows
"clockwise": clients, write side, read sides. Clients send Commands
to write side. Write side publishes Events to read sides. Read sides
reply to Queries for client.
2. The interesting logic is all in the write side, but your design may
consist *only* of the totality of Commands, Events, and Queries.
3. Each Command or Event has exactly one aggregate that it's acting on,
identified by unique aggregate ID. There need not be a one-to-one
@jaymecd
jaymecd / .README.md
Last active August 29, 2015 14:14 — forked from gnarf/..git-pr.md

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from GitHub remotes:

  • git pr 4 - creates local branch pr/4 from the origin remote and checks it out
  • git pr 4 upstream - creates local branch pr/4 from upstream remote and checks it out
@jaymecd
jaymecd / default.vcl
Last active August 29, 2015 14:15 — forked from benclark/default.vcl
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}
acl purge {
"localhost";

This is my response to an email asking about Domain-Driven Design in golang project.

Thank you for getting in touch. Below you will find my thoughts on how golang works with DDD, changing it. This is merely a perception of how things worked out for us in a single project.

That project has a relatively well-known domain. My colleagues on this project are very knowledgeable, thoughtful and invested in quality design. The story spelled out below is a result of countless hours spent discussing and refining the approach.

Conclusions could be very different, if there was a different project, team or a story-teller.

Short story

@jaymecd
jaymecd / main.go
Last active August 29, 2015 14:16 — forked from abdullin/main.go
package main
import (
"fmt"
"net/http"
)
var queue chan string
var joblist []string
@jaymecd
jaymecd / file_generator.php
Created March 4, 2015 22:59
Read file via generator
<?php
function getLine($file, $inFile = null, $asCsv = false)
{
$old = ini_set('auto_detect_line_endings', true);
if ($inFile) {
$file = sprintf('zip://%s#%s', $file, $inFile);
}
@jaymecd
jaymecd / CR_LF.md
Last active August 29, 2015 14:16 — forked from nickleefly/CR_LF.md

Permalink

danielmiessler.com | study | crlf

If you're like I used to be, you always have trouble remembering the difference between how Windows and Linux terminate lines in text files. Does Windows add the extra stuff, or does Linux? What exactly is the extra stuff? How do I get the stuff out?

Well, hopefully by the end of this you'll be taken care of once and for all.

The Characters