Skip to content

Instantly share code, notes, and snippets.

View vsavkin's full-sized avatar

Victor Savkin vsavkin

View GitHub Profile
@vsavkin
vsavkin / domain.md
Created August 25, 2012 14:23
Building Rich Domain Models in Rails

Building Rich Domain Models in Rails

Abstract

Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.

One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.

Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about here.

@vsavkin
vsavkin / rich_domain_models2.md
Created September 1, 2012 15:29
Building Rich Domain Models in Rails (revision 2)

Building Rich Domain Models in Rails.

Part 1. Decoupling Persistence.

Abstract

Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.

One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.

Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about in this article.

@vsavkin
vsavkin / crc.md
Created October 8, 2012 18:49
Using Pen & Paper. Part 1, CRC Cards

As programmers we tend to use software for solving absolutely all problems. Taking notes, brainstorming, time management. Everything is managed by some sort of software. And though often it makes a lot of sense to use an app, sometimes a piece of paper and a pen are better tools for the job.

This is the first blog post in a series about using low-tech tools for brainstorming, planning, and designing. I'd like to start by introducing one of the most interesting and, unfortunately, underused tools for brainstorming: CRC cards. CRC stands for Candidate, Responsibility, and Collaboration.

What are CRC cards?

CRC cards are index cards on which there are written:

  • A candidate's name
  • A candidate's information description. Just one or two sentences describing what each candidate is, and what it does.
library test_framework;
import 'package:unittest/unittest.dart';
// RSpec like framework
typedef Closure();
class Example {
String name;
Closure body;
@vsavkin
vsavkin / exampe.rb
Last active February 1, 2018 10:15
Example of using EDR
#somewhere in a controller
CreateOrder.new(OrderRepository).create current_user, params
# where
class CreateOrder < UseCaseService
def initialize order_repo
@order_repo = order_repo
var App = new Marionette.Application();
//This module is responsible for storing user data.
var userInfo = App.module("userInfo");
userInfo.addInitializer(function(){
App.reqres.setHandler("favouriteLanguages", function(user){
return ["JS", "Ruby"];
});
});
var App = new Marionette.Application();
//This object is responsible for storing user data.
var userInfo = {
favouriteLanguages: function(user){
return ["JS", "Ruby"];
}
};
//This module is responsible for displaying user data.
favouriteLanguages: function(user){
return ["JS", "Ruby"];
}
var languages = userInfo.favouriteLanguages("Victor");
App.reqres.setHandler("favouriteLanguages", function(user){
return ["JS", "Ruby"];
});
var languages = App.reqres.request("favouriteLanguages", "Victor");
expect(userInfo.favouriteLanguages).toHaveBeenCalledWith('Victor');