Last active
December 30, 2015 15:18
-
-
Save dasibre/7847127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before | |
class Moviegoer | |
attr_accessor :name, :street, :phone_number, :zip_code | |
validates :phone_number, #... | |
validates :zipcode, #... | |
def format_phone_number ; ... ; end | |
def verify_zipcode ; ... ; end | |
def format_address(street, phone_number, zipcode) #data_clump | |
#do formatting, calling format_phone_number and verify_zipcode | |
end | |
end | |
# After applying Extract Class: | |
class Moviegoer | |
attr_accessor :name | |
has_one :address | |
end | |
class Address | |
belongs_to :moviegoer | |
attr_accessor :phone_number, :zipcode | |
validates :phone_number, # ... | |
validates :zipcode, # ... | |
def format_address ; ... ; end # no arguments - operates on 'self' | |
private # no need to expose these now: | |
def format_phone_number ; ... ; end | |
def verify_zipcode ; ... ; end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment