Skip to content

Instantly share code, notes, and snippets.

@bbasata
bbasata / gist:3548170
Created August 31, 2012 02:34
"Where is your domain model?" : A Talk

Where is your domain model?

A domain model is much more than the “M” in MVC. As Martin Fowler writes, “Learning how to design and use a Domain Model is a significant exercise--one that has led to many articles on the ‘paradigm shift’ of objects use.”

Let’s talk about evolving a domain model in sustainable ways that allow a codebase to organically grow in a way that supports agility and adaptability. Highlights include:

  • What is a domain model? What are the alternatives?
  • What is sustainable software development?
  • Ubiquitous language, and thinking twice about naming something a Manager, Service, or DAO
@bbasata
bbasata / bowling_game_spec.rb
Created December 20, 2011 05:40
A bowling game
module Enumerable
def sum(identity=0)
inject(identity) { |sum,each| sum + each }
end
end
class BowlingGame
class Frame
def initialize
@rolls = []
@bbasata
bbasata / factorial_spec.rb
Created November 5, 2011 02:04
A simple example of RSpec
class Integer
def factorial
raise if self < 0
self > 0 ? (1..self).reduce(&:*) : 1
end
end
describe Integer, '#factorial' do
context "for values larger than 1" do
example { 2.factorial.should == 2*1 }
@bbasata
bbasata / StackTest.java
Created November 5, 2011 02:02
An example of BDD-influenced use of JUnit
import org.junit.Test;
import java.util.EmptyStackException;
import java.util.Stack;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
public class StackTest {
Stack<String> stack = new Stack<String>();
@bbasata
bbasata / bowling_game_spec.rb
Created November 5, 2011 01:49
How DRY & expressive can we get by making the subject a "let"-defined helper?
describe BowlingGame, '#score' do
subject { score }
let(:game) { BowlingGame.new }
let(:score) do
rolls.flatten.each { |roll| game.roll(roll) }
game.score
end
context "when there are no spares or strikes" do
context "all gutter balls" do
@bbasata
bbasata / jasmine-let.js
Created October 28, 2011 19:53
First draft: wondering if anyone else would love to see a RSpec-like lazy-initializing let() function introduced into @jasminebdd
function lazy(fn) {
return _.once(fn);
}
describe('Expired Item View', function() {
var item, view, rendered;
beforeEach(function() {
item = lazy(function() { return {}; });
view = lazy(function() { return new APP.Views.ExpiredItem({ item: item() }); });