On Github jonwolski / serp-presentation
The Single Essential Responsibility Principle
Jon Wolski
DaveRamsey.com
DevelopWithPurpose.com
I ♥ DESIGN
First, a little foundation…
incidental
Can software go bad?
It's code; it doesn't change unless you change it.
function calculate_tax_and_shipping(
line_item, shipping_address, billing_address ) {
var tax_amount =
line_item.price *
line_item.qty *
get_tax_rate_for_state( billing_address.state );
var shipping_amount = calculate_shipping_rate(
line_item.weight,
line_item.qty,
shipping_address
);
return tax_amount + shipping_amount;
}
function calculate_shipping( line_item, shipping_address ) {
return calculate_shipping_rate(
line_item.weight,
line_item.qty,
shipping_address
);
}
function calculate_tax( line_item, billing_address ) {
return line_item.get_total() *
get_tax_rate_for_state( billing_address.state );
}
class User < ActiveRecord::Base
has_many :accounts
def someBusinessDomainMethods
…
end
end
@entity
class Payment {
public someBusinessDomainMethods() {
…
}
}
Jon Wolski jon.wolski@daveramsey.com