therapeutic refactoring - flowcon sf 2014...
TRANSCRIPT
![Page 1: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/1.jpg)
Therapeutic Refactoring
Katrina OwenJumpstart Lab
@kytrinyx
![Page 2: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/2.jpg)
![Page 3: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/3.jpg)
Illustration from Am Adult by Allie Broshhttp://hyperboleandahalf.blogspot.com/2010/03/am-adult.html
![Page 4: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/4.jpg)
Photo: Johanna Owen 2011
![Page 5: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/5.jpg)
Illustration from U B Hatin’ by Allie Broshhttp://hyperboleandahalf.blogspot.com/2010/03/u-b-hatin.html
![Page 6: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/6.jpg)
I❤refactoring
![Page 7: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/7.jpg)
Illustration from There’s a Lesson in Here Somewhere, I Think by Allie Broshhttp://hyperboleandahalf.blogspot.com/2010/01/theres-lesson-in-here-somewhere-i-
think.html
![Page 8: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/8.jpg)
Illustration from There’s a Lesson in Here Somewhere, I Think by Allie Broshhttp://hyperboleandahalf.blogspot.com/2010/01/theres-lesson-in-here-somewhere-i-
think.html
![Page 9: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/9.jpg)
refactoringis not
rehacktoring
![Page 10: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/10.jpg)
Inspired by true events
A Story
![Page 11: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/11.jpg)
Illustration from The Scariest Story by Allie Broshhttp://hyperboleandahalf.blogspot.com/2011/02/scariest-story.html
![Page 12: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/12.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 13: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/13.jpg)
Illustration from The Scariest Story by Allie Broshhttp://hyperboleandahalf.blogspot.com/2011/02/scariest-story.html
![Page 14: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/14.jpg)
Illustration from The Scariest Story by Allie Broshhttp://hyperboleandahalf.blogspot.com/2011/02/scariest-story.html
![Page 15: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/15.jpg)
Illustration from The Scariest Story by Allie Broshhttp://hyperboleandahalf.blogspot.com/2011/02/scariest-story.html
![Page 16: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/16.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 17: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/17.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 18: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/18.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 19: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/19.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 20: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/20.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 21: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/21.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 22: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/22.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 23: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/23.jpg)
![Page 24: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/24.jpg)
(the first middle)
Tests
![Page 25: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/25.jpg)
describe XYZService doend
![Page 26: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/26.jpg)
describe XYZService do
it "works" do end
end
![Page 27: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/27.jpg)
describe XYZService do
subject { XYZService.xyz_filename(stub) }
it "works" do end
end
![Page 28: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/28.jpg)
describe XYZService do
subject { XYZService.xyz_filename(stub) }
it "works" do end
end
![Page 29: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/29.jpg)
describe XYZService do
subject { XYZService.xyz_filename(stub) }
it "works" do end
end
![Page 30: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/30.jpg)
describe XYZService do
subject { XYZService.xyz_filename(stub) }
it "works" do subject.should eq("something") end
end
![Page 31: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/31.jpg)
subject.should eq "something"
![Page 32: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/32.jpg)
subject.should eq "whatever"
![Page 33: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/33.jpg)
subject.should eq "freddy"
![Page 34: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/34.jpg)
subject.should eq "something"
![Page 35: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/35.jpg)
Failures:
1) XYZService works
Failure/Error: subject.should eq("something")
Stub received unexpected message :publish_on with (no args)
# ./xyz_service.rb:6:in `xyz_filename'
![Page 36: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/36.jpg)
Failures:
1) XYZService works
Failure/Error: subject.should eq("something")
Stub received unexpected message :publish_on with (no args)
# ./xyz_service.rb:6:in `xyz_filename'
![Page 37: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/37.jpg)
Stub received unexpected message
:publish_onwith (no args)
![Page 38: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/38.jpg)
Failures:
1) XYZService works
Failure/Error: subject.should eq("something")
Stub received unexpected message :publish_on with (no args)
# ./xyz_service.rb:6:in `xyz_filename'
![Page 39: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/39.jpg)
# ./xyz_service.rb:6
![Page 40: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/40.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 41: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/41.jpg)
target.publish_on.strftime("%d")
![Page 42: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/42.jpg)
target.publish_on.strftime("%d")
![Page 43: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/43.jpg)
target.publish_on.strftime("%d")
![Page 44: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/44.jpg)
describe XYZService do
subject { XYZService.xyz_filename(stub) }
it "works" do end
end
![Page 45: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/45.jpg)
describe XYZService do
subject { XYZService.xyz_filename(target) }
it "works" do end
end
![Page 46: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/46.jpg)
describe XYZService do
let(:target) do stub(:target) end
subject { XYZService.xyz_filename(target) }
it "works" do subject.should eq("something") end
end
![Page 47: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/47.jpg)
describe XYZService do
let(:target) do messages = { } stub(:target, messages) end
subject { XYZService.xyz_filename(target) }
it "works" do subject.should eq("something") end
end
![Page 48: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/48.jpg)
describe XYZService do
let(:target) do messages = { :publish_on => ? } stub(:target, messages) end
subject { XYZService.xyz_filename(target) }
it "works" do subject.should eq("something") end
end
![Page 49: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/49.jpg)
describe XYZService do
let(:target) do messages = { :publish_on => Date.new(2012, 3, 14) } stub(:target, messages) end
subject { XYZService.xyz_filename(target) }
it "works" do subject.should eq("something") end
end
![Page 50: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/50.jpg)
Stub received unexpected message
:xyz_category_prefixwith (no args)
![Page 51: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/51.jpg)
...
:xyz_category_prefix => ?,
...
![Page 52: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/52.jpg)
...
:xyz_category_prefix => 'abc',
...
![Page 53: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/53.jpg)
Stub received unexpected message
:kindwith (no args)
![Page 54: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/54.jpg)
...
:kind => ?
...
![Page 55: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/55.jpg)
...
:kind => 'unicorn'
...
![Page 56: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/56.jpg)
Stub received unexpected message
:personal?with (no args)
![Page 57: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/57.jpg)
...
:personal? => ?
...
![Page 58: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/58.jpg)
...
:personal? => false
...
![Page 59: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/59.jpg)
Stub received unexpected message
:idwith (no args)
![Page 60: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/60.jpg)
...
:id => ?
...
![Page 61: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/61.jpg)
...
:id => 1337
...
![Page 62: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/62.jpg)
Stub received unexpected message
:titlewith (no args)
![Page 63: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/63.jpg)
...
:title => ?
...
![Page 64: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/64.jpg)
...
:title => 'magic & superglue'
...
![Page 65: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/65.jpg)
Failures:
1) XYZService works
Failure/Error: subject.should eq("something")
expected: "something"
got: "14abcunicorn_1337_3f4894ca_magicsuper.jpg"
(compared using ==)
# ./xyz_file_spec.rb:18:in `block (2 levels) in <top (required)>
![Page 66: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/66.jpg)
Failures:
1) XYZService works
Failure/Error: subject.should eq("something")
expected: "something"
got: "14abcunicorn_42_3f4894ca_magicsuper.jpg"
(compared using ==)
# ./xyz_file_spec.rb:18:in `block (2 levels) in <top (required)>
#WIN
![Page 67: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/67.jpg)
let(:target) do messages = { :publish_on => Date.new(2012, 3, 14), :xyz_category_prefix => 'abc', :kind => 'unicorn', :personal? => false, :id => 1337, :title => 'magic & superglue' } stub(:target, messages) end
![Page 68: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/68.jpg)
Failures:
1) XYZService works
Failure/Error: subject.should eq("something")
expected: "something"
got: "14abcunicorn_1337_3f4894ca_magicsuper.jpg"
(compared using ==)
# ./xyz_file_spec.rb:18:in `block (2 levels) in <top (required)>
![Page 69: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/69.jpg)
Failures:
1) XYZService works
Failure/Error: subject.should eq("something")
expected: "something"
got: "14abcunicorn_1337_3f4894ca_magicsuper.jpg"
(compared using ==)
# ./xyz_file_spec.rb:18:in `block (2 levels) in <top (required)>
![Page 70: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/70.jpg)
14abcunicorn_1337_3f4894ca_magicsuper.jpg
![Page 71: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/71.jpg)
14abcunicorn_1337_3f4894ca_magicsuper.jpg
![Page 72: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/72.jpg)
subject.should eq "14abcunicorn_1337_3f4894ca_magicsuper.jpg"
![Page 73: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/73.jpg)
expected
"14abcunicorn_1337_3f4894ca_magicsuper.jpg"
got
"14abcunicorn_1337_59a2b50d_magicsuper.jpg"
![Page 74: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/74.jpg)
expected
"14abcunicorn_1337_3f4894ca_magicsuper.jpg"
got
"14abcunicorn_1337_59a2b50d_magicsuper.jpg"
![Page 75: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/75.jpg)
subject.should eq "14abcunicorn_1337_3f4894ca_magicsuper.jpg"
![Page 76: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/76.jpg)
subject.should match/14abcunicorn_1337_[0-9a-f]{8}_magicsuper.jpg/
![Page 77: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/77.jpg)
.
Finished in 0.00073 seconds
1 example, 0 failures
![Page 78: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/78.jpg)
.
Finished in 0.00073 seconds
1 example, 0 failures#WIN
![Page 79: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/79.jpg)
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
![Page 80: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/80.jpg)
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
![Page 81: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/81.jpg)
Illustration from The Scariest Story by Allie Broshhttp://hyperboleandahalf.blogspot.com/2011/02/scariest-story.html
![Page 82: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/82.jpg)
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
![Page 83: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/83.jpg)
target.publish_on.strftime("%d")
![Page 84: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/84.jpg)
:publish_on => Date.new(2012, 3, 14)
![Page 85: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/85.jpg)
:publish_on => Date.new(2012, 2, 7)
![Page 86: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/86.jpg)
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
![Page 87: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/87.jpg)
target.kind.gsub("_", "")
![Page 88: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/88.jpg)
:kind => 'unicorn'
![Page 89: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/89.jpg)
:kind => 'magic_unicorn'
![Page 90: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/90.jpg)
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
![Page 91: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/91.jpg)
target.title.gsub(/[^\[a-z\]]/i, '').
downcase
![Page 92: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/92.jpg)
:title => 'magic & superglue'
![Page 93: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/93.jpg)
:title => 'I <3 Sparkles!!1!'
![Page 94: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/94.jpg)
Illustration from Bycicle by Allie Broshhttp://hyperboleandahalf.blogspot.no/2010/07/bicycle.html
![Page 95: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/95.jpg)
target.title.gsub(/[^\[a-z\]]/i, '').
downcase
![Page 96: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/96.jpg)
target.title.gsub(/[^\[a-z\]]/i, '').
downcase
![Page 97: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/97.jpg)
it "works" { ... } it "leaves square brackets???"
![Page 98: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/98.jpg)
it "leaves square brackets???" do target.stub(:title => 'i[sparkle]s') end
![Page 99: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/99.jpg)
expected
"07abcmagicunicorn_1337_f3b6d325_i[sparkle].jpg"
to match
/07abcmagicunicorn_1337_[0-9a-z]{8}_isparkles.jpg/
![Page 100: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/100.jpg)
it "works"{ ... } it "leaves square brackets"{ ... }
![Page 101: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/101.jpg)
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
![Page 102: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/102.jpg)
"_%03d" % (target.age || 0)
if target.personal?
![Page 103: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/103.jpg)
"_%03d" % (target.age || 0)
if target.personal?
![Page 104: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/104.jpg)
it "works" { ... } it "leaves square brackets"{ ... } it "personalizes"
![Page 105: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/105.jpg)
it "personalizes" do target.stub(:personal? => true) end
![Page 106: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/106.jpg)
Stub received unexpected message
:agewith (no args)
![Page 107: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/107.jpg)
it "personalizes" do target.stub(:personal? => true) target.stub(:age? => 42) end
![Page 108: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/108.jpg)
"_%03d" % (target.age || 0)
if target.personal?
![Page 109: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/109.jpg)
"_%03d" % (target.age || 0)
if target.personal?
![Page 110: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/110.jpg)
it "works"{ ... } it "leaves square brackets"{ ... } it "personalizes"{ ... } it "handles nil age"
![Page 111: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/111.jpg)
it "handles nil age" do target.stub(:personal? => true) target.stub(:age? => nil) end
![Page 112: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/112.jpg)
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
![Page 113: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/113.jpg)
length > 9 ? 9 : length
![Page 114: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/114.jpg)
:title => 'I <3 Sparkles!!1!'
![Page 115: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/115.jpg)
:title => 'I <3 SPARKLY Sparkles!!1!'
![Page 116: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/116.jpg)
it "works" { ... } it "leaves square brackets" { ... } it "personalizes" { ... } it "handles nil age" { ... } it "handles short titles"
![Page 117: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/117.jpg)
it "handles short titles" do target.stub(:title => ‘O HAI’) end
![Page 118: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/118.jpg)
.....
Finished in 0.00386 seconds
5 examples, 0 failures
![Page 119: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/119.jpg)
.....
Finished in 0.00386 seconds
5 examples, 0 failures#WIN
![Page 120: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/120.jpg)
Illustration from This is Why I’ll Never be an Adult by Allie Broshhttp://hyperboleandahalf.blogspot.com/2010/06/this-is-why-ill-never-be-adult.html
![Page 121: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/121.jpg)
Text
![Page 122: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/122.jpg)
(the second middle)
Refactoring
![Page 123: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/123.jpg)
replace methodwith method object
Refactoring
![Page 124: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/124.jpg)
class XYZFileend
![Page 125: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/125.jpg)
class XYZFile
def initialize(target) end
end
![Page 126: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/126.jpg)
class XYZFile
attr_reader :target def initialize(target) @target = target end
end
![Page 127: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/127.jpg)
class XYZFile
attr_reader :target def initialize(target) @target = target end
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 128: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/128.jpg)
class XYZFile
...
def self.xyz_filename(target) ... end
end
![Page 129: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/129.jpg)
class XYZFile
...
def xyz_filename(target) ... end
end
![Page 130: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/130.jpg)
class XYZFile
...
def name(target) ... end
end
![Page 131: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/131.jpg)
class XYZFile
...
def name ... end
end
![Page 132: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/132.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 133: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/133.jpg)
module XYZService
def self.xyz_filename(target) end
end
![Page 134: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/134.jpg)
require_relative './xyz_file'
module XYZService
def self.xyz_filename(target) end
end
![Page 135: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/135.jpg)
require_relative './xyz_file'
module XYZService
def self.xyz_filename(target) XYZFile.new end
end
![Page 136: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/136.jpg)
require_relative './xyz_file'
module XYZService
def self.xyz_filename(target) XYZFile.new end
end
(target)(target)
![Page 137: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/137.jpg)
require_relative './xyz_file'
module XYZService
def self.xyz_filename(target) XYZFile.new end
end
(target)(target).name
![Page 138: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/138.jpg)
.....
Finished in 0.00398 seconds
5 examples, 0 failures
![Page 139: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/139.jpg)
.....
Finished in 0.00398 seconds
5 examples, 0 failures#WIN
![Page 140: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/140.jpg)
class XYZFile ... def name # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 141: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/141.jpg)
class XYZFile ... def name # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 142: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/142.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 143: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/143.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 144: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/144.jpg)
class XYZFile ... def name ... truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" ... end
end
![Page 145: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/145.jpg)
class XYZFile ... def name ... truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" ... end
end
![Page 146: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/146.jpg)
class XYZFile ... def name ... truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" ... end
def truncated_title end
end
![Page 147: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/147.jpg)
class XYZFile ... def name ... truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" ... end
def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" end
end
![Page 148: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/148.jpg)
class XYZFile ... def name...
def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" end
end
![Page 149: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/149.jpg)
class XYZFile ... def name...
def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" end
end
![Page 150: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/150.jpg)
class XYZFile ... def name...
def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" end
end
![Page 151: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/151.jpg)
class XYZFile ... def name...
def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length truncated_title[0..(truncate_to)] end
end
![Page 152: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/152.jpg)
class XYZFile ... def name...
def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length truncated_title[0..(truncate_to)] end
end
![Page 153: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/153.jpg)
class XYZFile ... def name ... truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" ... end
def truncated_title...
end
![Page 154: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/154.jpg)
class XYZFile ... def name ... truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title}" ... end
def truncated_title...
end
![Page 155: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/155.jpg)
class XYZFile ... def name ... truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title}" ... end
def truncated_title...end
![Page 156: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/156.jpg)
class XYZFile ... def name ... filename << "_#{truncated_title}" ... end
def truncated_title...
end
![Page 157: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/157.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def truncated_title...
end
![Page 158: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/158.jpg)
class XYZFile ... def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length truncated_title[0..(truncate_to)] end
end
![Page 159: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/159.jpg)
class XYZFile ... def truncated_title truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length truncated_title[0..(truncate_to)] end
end
![Page 160: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/160.jpg)
target.title.gsub(/[^\[a-z\]]/i, '').
downcase
![Page 161: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/161.jpg)
target.title.gsub(/[^\[a-z\]]/i, '').
downcase
![Page 162: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/162.jpg)
target.title.gsub(/[^\[a-z\]]/i, '').
downcase
![Page 163: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/163.jpg)
target.title.downcasegsub(/[^\[a-z\]]/, '')
![Page 164: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/164.jpg)
truncated_title[0..(truncate_to)]
![Page 165: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/165.jpg)
truncated_title[0..(truncate_to)]
![Page 166: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/166.jpg)
truncated_title[0..truncate_to]
![Page 167: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/167.jpg)
truncate_to = length > 9 ? 9 : lengthtruncated_title[0..truncate_to]
![Page 168: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/168.jpg)
truncate_to = length > 9 ? 9 : length
truncated_title[0..9]
![Page 169: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/169.jpg)
length = truncated_title.lengthtruncate_to = length > 9 ? 9 : length
truncated_title[0..9]
![Page 170: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/170.jpg)
length = truncated_title.lengthtruncate_to = length > 9 ? 9 : length
truncated_title[0..9]
![Page 171: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/171.jpg)
class XYZFile ... def truncated_title truncated_title = target.title.downcase.gsub(/[^\[a-z\]]/, '') truncated_title[0..truncate_to] end
end
![Page 172: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/172.jpg)
class XYZFile ... def truncated_title truncated_title = target.title.downcase.gsub(/[^\[a-z\]]/, '') truncated_title[0..truncate_to] end
end
![Page 173: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/173.jpg)
class XYZFile ... def truncated_title target.title.downcase. gsub(/[^\[a-z\]]/, '')[0..9] end
end
![Page 174: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/174.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def truncated_title...
end
![Page 175: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/175.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def truncated_title...
end
![Page 176: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/176.jpg)
class XYZFile ... def name ... filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" ... end
def truncated_title...
end
![Page 177: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/177.jpg)
class XYZFile ... def name ... filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" ... end
def noise end
def truncated_title...
end
![Page 178: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/178.jpg)
class XYZFile ... def name ... filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" ... end
def noise Digest::SHA1.hexdigest(rand(10000).to_s)[0,8] end
def truncated_title...
end
![Page 179: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/179.jpg)
class XYZFile ... def name ... filename << "_#{noise}" ... end
def noise Digest::SHA1.hexdigest(rand(10000).to_s)[0,8] end
def truncated_title...
end
![Page 180: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/180.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def noise...
def truncated_title...
end
![Page 181: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/181.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def noise...
def truncated_title...
end
![Page 182: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/182.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def age "%03d" % (target.age || 0) end
def noise...
def truncated_title...
end
![Page 183: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/183.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def age...
def noise...
def truncated_title...
end
![Page 184: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/184.jpg)
class XYZFile ... def name filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def age...
def noise...
def truncated_title...
end
![Page 185: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/185.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def publication_day target.publish_on.strftime("%d") end
def age...
def noise...
def truncated_title...
end
![Page 186: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/186.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def publication_day...
def age...
def noise...
def truncated_title...
end
![Page 187: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/187.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def publication_day...
def age...
def noise...
def truncated_title...
end
![Page 188: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/188.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{category}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def category target.xyz_category_prefix end
def publication_day...
def age...
def noise...
def truncated_title...
end
![Page 189: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/189.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{category}" filename << "#{target.kind.gsub("_", "")}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def publication_day...
def category...
def age...
def noise...
def truncated_title...
end
![Page 190: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/190.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{category}" filename << "#{kind}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def kind target.kind.gsub("_", "") end
def publication_day...
def category...
def age...
def noise...
def truncated_title...
end
![Page 191: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/191.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{category}" filename << "#{kind}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def publication_day... def category... def kind... def age... def noise... def truncated_title...
end
![Page 192: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/192.jpg)
class XYZFile ... def name filename = "#{publication_day}" filename << "#{category}" filename << "#{kind}" filename << "_#{age}" if target.personal? filename << "_#{target.id.to_s}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" return filename end
def publication_day... def category... def kind... def age... def noise... def truncated_title...
end
![Page 193: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/193.jpg)
filename = "#{publication_day}"
![Page 194: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/194.jpg)
filename = "#{publication_day}"
![Page 195: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/195.jpg)
filename = publication_day
![Page 196: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/196.jpg)
filename << "#{category}"
![Page 197: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/197.jpg)
filename << category
![Page 198: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/198.jpg)
filename << "#{kind}"
![Page 199: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/199.jpg)
filename << kind
![Page 200: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/200.jpg)
filename << "_#{target.id.to_s}"
![Page 201: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/201.jpg)
filename << "_#{target.id}"
![Page 202: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/202.jpg)
class XYZFile ... def name filename = publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" filename end ...end
![Page 203: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/203.jpg)
class XYZFile ... def name filename = publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" filename end ...end
![Page 204: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/204.jpg)
class XYZFile ... def name filename = publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" filename end ...end
![Page 205: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/205.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" filename end ...end
![Page 206: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/206.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" filename end ...end
![Page 207: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/207.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" filename end ...end
![Page 208: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/208.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" filename << ".jpg" filename end ...end
![Page 209: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/209.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 210: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/210.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 211: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/211.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 212: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/212.jpg)
class XYZFile ... def name filename = "" filename << publication_day filename << category filename << kind filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 213: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/213.jpg)
class XYZFile ... def name ... filename << publication_day filename << category filename << kind ... end ...end
![Page 214: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/214.jpg)
class XYZFile ... def name ... filename << publication_day filename << category filename << kind ... end
def prefix [publication_day, category, kind].join end
...end
![Page 215: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/215.jpg)
class XYZFile ... def name ... filename << prefix ... end
def prefix [publication_day, category, kind].join end
...end
![Page 216: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/216.jpg)
class XYZFile ... def name filename = "" filename << prefix filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 217: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/217.jpg)
class XYZFile ... def name filename = "" filename << prefix filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 218: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/218.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 219: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/219.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << "_#{age}" if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 220: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/220.jpg)
class XYZFile ... def name filename = "" filename << prefix filename << age if target.personal? filename << "_#{target.id}" filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 221: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/221.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << "_#{noise}" filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 222: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/222.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << noise filename << "_#{truncated_title}" "#{filename}.jpg" end ...end
![Page 223: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/223.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << noise filename << truncated_title "#{filename}.jpg" end ...end
![Page 224: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/224.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << noise filename << truncated_title "#{filename.join("_")}.jpg" end ...end
![Page 225: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/225.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << noise filename << truncated_title "#{filename.join("_")}.jpg" end
def prefix... def publication_day... def category... def kind... def age... def noise... def truncated_title... ...end
![Page 226: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/226.jpg)
Illustration from About by Allie Broshhttp://hyperboleandahalf.blogspot.com/p/about.html
![Page 227: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/227.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 228: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/228.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << noise filename << truncated_title "#{filename.join("_")}.jpg" end
def prefix... def publication_day... def category... def kind... def age... def noise... def truncated_title... ...end
![Page 229: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/229.jpg)
class XYZFile ... def prefix [publication_day, category, kind].join end
def publication_day target.publish_on.strftime("%d") end
def category target.xyz_category_prefix end
def kind target.kind.gsub("_", "") end
def age "%03d" % (target.age || 0) end
def noise Digest::SHA1.hexdigest(rand(10000).to_s)[0,8] end
def truncated_title target.title.downcase.gsub(/[^\[a-z\]]/, '')[0..9] end
end
![Page 230: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/230.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 231: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/231.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << noise filename << truncated_title "#{filename.join("_")}.jpg" end
def prefix... def publication_day... def category... def kind... def age... def noise... def truncated_title... ...end
![Page 232: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/232.jpg)
module XYZService
def self.xyz_filename(target) # File format: # [day of month zero-padded][three-letter prefix] \ # _[kind]_[age_if_kind_personal]_[target.id] \ # _[8 random chars]_[10 first chars of title].jpg filename = "#{target.publish_on.strftime("%d")}" filename << "#{target.xyz_category_prefix}" filename << "#{target.kind.gsub("_", "")}" filename << "_%03d" % (target.age || 0) if target.personal? filename << "_#{target.id.to_s}" filename << "_#{Digest::SHA1.hexdigest(rand(10000).to_s)[0,8]}" truncated_title = target.title.gsub(/[^\[a-z\]]/i, '').downcase length = truncated_title.length truncate_to = length > 9 ? 9 : length filename << "_#{truncated_title[0..(truncate_to)]}" filename << ".jpg" return filename end
end
![Page 233: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/233.jpg)
class XYZFile ... def name filename = [] filename << prefix filename << age if target.personal? filename << target.id filename << noise filename << truncated_title "#{filename.join("_")}.jpg" end
def prefix... def publication_day... def category... def kind... def age... def noise... def truncated_title... ...end
![Page 234: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/234.jpg)
Text
![Page 235: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/235.jpg)
(the ending)
Codejunk
![Page 236: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/236.jpg)
Illustration from Chartjunk by Viveka Weileyhttp://chartjunk.karmanaut.com/?p=8
![Page 237: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/237.jpg)
Illustration from Chartjunk by Viveka Weileyhttp://chartjunk.karmanaut.com/test-pattern-retuned/
![Page 238: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/238.jpg)
(in no particular order)
Top 10
![Page 239: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/239.jpg)
Lousy Comments
#10
![Page 240: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/240.jpg)
module Codejunk
# States the obvious def state_the_obvious "whatever" end
end
![Page 241: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/241.jpg)
module Codejunk
# Takes modulus 100 def say_it_again(number) number % 100 end
end
![Page 242: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/242.jpg)
module Codejunk
# Subtracts def incorrect_comment 1 + 1 end
end
![Page 243: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/243.jpg)
module Codejunk
# add def fuzzy_comment 1 + 1 end
end
![Page 244: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/244.jpg)
module Codejunk
# ad too numbers def bad_comment 1 + 2 end
end
![Page 245: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/245.jpg)
Trailing Whitespace
#9
![Page 246: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/246.jpg)
module Codejunk def a_method 'Use your words' end end
...................
.................
......
..
..
.
..
![Page 247: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/247.jpg)
Commented-Out Code
#8
![Page 248: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/248.jpg)
module Codejunk
def tweaked_logic(wday) # ((7 - wday) % 7) * 1.day (7 - wday) % 7 end
end
![Page 249: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/249.jpg)
module Codejunk
def tweaked_logic(wday) if false ((7 - wday) % 7) * 1.day end (7 - wday) % 7 end
end
![Page 250: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/250.jpg)
Needless Parentheses
#7
![Page 251: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/251.jpg)
module Codejunk
def spurious_parentheses() junk() end
end
![Page 252: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/252.jpg)
module Codejunk
def more_spurious_parentheses (0..(one_method_call)).to_a end
def one_method_call (10 - rand(10)) end
end
![Page 253: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/253.jpg)
Powerless Code
#6
![Page 254: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/254.jpg)
module Codejunk
def spurious_arguments [1, 2, 3].join('') end
end
![Page 255: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/255.jpg)
module Codejunk
def spurious_arguments [1, 2, 3].join end
end
![Page 256: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/256.jpg)
class ObjectWrapper
attr_accessor :object def initialize(object) @object = object end
end
![Page 257: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/257.jpg)
module Codejunk
def extract(response) if (200..299).include?(response.code.to_i) response.body if response end end
end
![Page 258: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/258.jpg)
module Codejunk
def extract(response) if (200..299).include?(response.code.to_i) response.body if response end end
end
![Page 259: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/259.jpg)
module Codejunk
def extract(response) if (200..299).include?(response.code.to_i) response.body if response end end
end
![Page 260: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/260.jpg)
Unnecessary Requires
#5
![Page 261: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/261.jpg)
require 'active_support/all'
# Nothing uses active supportmodule Codejunk ...end
![Page 262: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/262.jpg)
The booleanest boolean
#4
![Page 263: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/263.jpg)
module Codejunk
def truth(code) code == 13 ? true : false end
end
![Page 264: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/264.jpg)
module Codejunk
def lie! !true end
end
![Page 265: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/265.jpg)
Too Much Hard Work
#3
![Page 266: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/266.jpg)
module Codejunk
def spurious_string_interpolation "#{thing}" end
def thing "a string" end
end
![Page 267: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/267.jpg)
module Codejunk
def spurious_stringification "I am #{age.to_s} years old" end
def age rand(25) + 15 end
end
![Page 268: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/268.jpg)
module Codejunk
def spurious_transformations [1, 2, 3].map(&:to_s).join end
end
![Page 269: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/269.jpg)
module Codejunk
def spurious_complexity s = rand(2) == 0 ? "abcde" : "abc" cutoff = s.length > 4 ? 4 : s.length s[0..cutoff] end
end
![Page 270: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/270.jpg)
module Codejunk
def spurious_hard_work s = "I <3 Magic!" s.gsub(/[^a-z]/i, '').downcase end
end
![Page 271: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/271.jpg)
Duplicated Tests
#2
![Page 272: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/272.jpg)
module Codejunk def add(n1, n2) n1 + n2 endend
describe Codejunk do subject { stub.extend(Codejunk) }
it "adds" do subject.add(1, 1).should eq(2) end
it "adds twin primes" do subject.add(29, 31).should eq(60) end
it "adds big numbers" do subject.add(9238498, 2039238).should eq(11277736) end
it "adds negative numbers" do subject.add(100, -390).should eq(-290) end
end
![Page 273: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/273.jpg)
describe Codejunk do
subject { stub.extend(Codejunk) }
it "gets rid of spaces" do subject.sanitize(" o m g ").should eq('omg') end
it "gets rid of funky characters" do subject.sanitize("omg^%#=}{?_").should eq('omg') end
it "gets rid of numbers" do subject.sanitize("omg123").should eq('omg') end
it "downcases everything" do subject.sanitize("OMG").should eq('omg') end
end
![Page 274: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/274.jpg)
Combine All The Codejunk
#1
![Page 275: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/275.jpg)
module Codejunk
def junk # Subtracts s = rand(2) == 0 ? "abcde" : "abc" cutoff = s.length > 4 ? 4 : s.length s = s[0..cutoff] s << "#{spurious_string_interpolation()}" s << "I am #{age.to_s} years old, and " s << "I <3 Magic!".gsub(/[^a-z]/i, '').downcase s << "#{(0..(one_method_call)).map(&:to_s).join('')}" return s end
end
![Page 276: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/276.jpg)
Text
![Page 277: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/277.jpg)
github.com/kytrinyx /therapeutic-refactoring
![Page 278: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/278.jpg)
Refactoring by Martin Fowler et al.http://www.goodreads.com/book/show/44936.Refactoring
Refactoring, Ruby Edition by Jay Fields et al.http://www.goodreads.com/book/show/11560939-refactoring
![Page 279: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/279.jpg)
Working Effectively With Legacy Code by Michael Feathershttp://www.goodreads.com/book/show/44919.Working_Effectively_with_Legacy_Code
![Page 280: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/280.jpg)
Practical Object-Oriented Design in Ruby by Sandi Metzhttp://www.goodreads.com/book/show/13507787-practical-object-oriented-design-in-ruby
![Page 281: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/281.jpg)
(the moral)
Therapy
![Page 282: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/282.jpg)
![Page 283: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/283.jpg)
I❤refactoring
![Page 284: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/284.jpg)
Working Memory
Science!
* Beilock & DeCaro, Department of Psychology, University of Chicagohttp://www.ncbi.nlm.nih.gov/pubmed/17983308
![Page 285: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/285.jpg)
Problem-Solving Strategies
Science!
![Page 286: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/286.jpg)
Worry & Panic
Science!
![Page 287: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/287.jpg)
makes you smarter!
Refactoring
![Page 288: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/288.jpg)
Exobrain
![Page 289: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/289.jpg)
counteracts panic
Exobrain
![Page 290: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/290.jpg)
makes you happier!
Refactoring
![Page 291: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/291.jpg)
Fast Tests
![Page 292: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/292.jpg)
are awesome
Fast Tests
![Page 293: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/293.jpg)
Happiness
![Page 294: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/294.jpg)
leads to good design
Happiness
![Page 295: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/295.jpg)
Illustration from God of Cake by Allie Broshhttp://hyperboleandahalf.blogspot.no/2010/10/god-of-cake.html
![Page 296: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/296.jpg)
exobrain
Illustration from God of Cake by Allie Broshhttp://hyperboleandahalf.blogspot.no/2010/10/god-of-cake.html
![Page 297: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/297.jpg)
Illustration from God of Cake by Allie Broshhttp://hyperboleandahalf.blogspot.no/2010/10/god-of-cake.html
prevents panic
![Page 298: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/298.jpg)
Illustration from God of Cake by Allie Broshhttp://hyperboleandahalf.blogspot.no/2010/10/god-of-cake.html
happiness
![Page 299: Therapeutic Refactoring - Flowcon SF 2014 Conferenceflowcon.org/.../KatrinaOwen_TherapeuticRefactoring.pdf · 2013. 11. 1. · module XYZService def self.xyz_filename(target) # File](https://reader035.vdocument.in/reader035/viewer/2022062605/5fc6db1700584e50331c2b84/html5/thumbnails/299.jpg)
Illustration from God of Cake by Allie Broshhttp://hyperboleandahalf.blogspot.no/2010/10/god-of-cake.html
decoupled code