Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (71 sloc) 2.31 KB
Mirror displays - fn + f7
Intro - 1 min
* last time!
* I work at thoughtbot
* this is pairing
data_clump.rb - 24 minutes, spend less time on coupling, 3-21 (18.5)
* I have specs
* roughly a B
* move temp to query for orders_within_range
* shorter methods
* can reuse
* don't have to read it
* hints that implementation details are unimportant
* move select to Order#placed_between?(@start_date, @end_date)
* identify data clump, passed in three places
* extract to DateRange
* start by instantiating in Order
* then invert control, placing in spec
* smaller steps are good
* immediate win: coupling is reduced
* the degree to which components rely on each other
* fewer arguments is less coupling
* nice place to hang an #include? method (Corey Haines "behavior magnets")
* Value Object
* move placed_between? to DateRange#include?
* refactor include? to use a range: (start_date..end_date).cover?(date)
* DateRange can just be subclassed from Range
* create private Order#total_sales
* worsened coupling, maybe we want OrdersCollection
* change to inject(&:+)
* NYANCAT
NyanCat
null_object.rb - 6 m, 22-28; 19-24 5m
* problems
* feature envy / TDA
* co-opts nil to stand in for 'no customer'
* obscures the true intent of the code
* create NullCustomer
* Poll: who has code like "if current_user ; ... ; end"
depend_upon_abstractions.rb
* key idea to ease change: depend on abstractions
* just because it's in a gem doesn't mean it's abstracted
* problems:
* divergent change
* we'll have to stub out someone else's code
* depend_upon_abstractions_fixed.rb
* easy to change gems or providers
* easy to mock
* nice place to hang constants
* adapter pattern
* inversion of control allows us to swap in a different implementation when Braintree is down, with none of the objects that use the Gateway knowing
when to refactor - 5m
* after every change you make
* god objects
* wc -l
* high churn files
* bugs love company
plugs
* learn.thoughtbot.com
Setup:
clear history
print notes
clean repo
get directory in anonymized/
open churn in tab
phone to no lock
make sure temp extraction method works
ddjjddkkVjdjjjko def orders pjoendkkVj<jxkkkoprivate 
make sure undo works
Something went wrong with that request. Please try again.