-Friday, May 10, 13
YANN ARMAND-@yarmandFriday, May 10, 13
-The Enterprise Social NetworkFriday, May 10, 13
Friday, May 10, 13
DELETE A DB COLUMNWITHOUT MAKING ZOMBIESFriday, May 10, 13
DELETE A DB COLUMNWITHOUT MAKING ZOMBIESFriday, May 10, 13
WHY DELETE A MODELATTRIBUTE ?-Friday, May 10, 13
WHY DELETE A MODELATTRIBUTE ?• Not used anymore-Friday, May 10, 13
WHY DELETE A MODELATTRIBUTE ?• Not used anymoreUser Payment card• card_type• card_number• Move to another model-Friday, Ma...
KILLING AN ACTIVE RECORDFIELDCons-Friday, May 10, 13
KILLING AN ACTIVE RECORDFIELD• Code dependencyCons-Friday, May 10, 13
KILLING AN ACTIVE RECORDFIELD• Code dependencyCons• Unknown impact on the app behavior-Friday, May 10, 13
KILLING AN ACTIVE RECORDFIELD• Code dependencyCons• Unknown impact on the app behavior-Friday, May 10, 13
KILLING AN ACTIVE RECORDFIELD• Code dependencyCons• Unknown impact on the app behavior-Friday, May 10, 13
KILL AN ACTIVE RECORDFIELDPros-Friday, May 10, 13
KILL AN ACTIVE RECORDFIELDPros• ReduceTechnical Debt-Friday, May 10, 13
KILL AN ACTIVE RECORDFIELDPros• ReduceTechnical Debt• Smaller code base• Lower barrier of entry-• Eliminate black holes• P...
BE PREPARED !!-Friday, May 10, 13
BE PREPARED !!-Friday, May 10, 13
BE PREPARED !!-Friday, May 10, 13
class Userdeprecate_attribute :card_typedeprecate_attribute :card_numberend-Friday, May 10, 13
API OUTPUTrender :json => username: rogerage: 23card_type: visacard_number: 123412341234name: rogerage: 23-Friday, May 10,...
API OUTPUTrender :json => username: rogerage: 23card_type: visacard_number: 123412341234name: rogerage: 23-ActiveRecord#se...
API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.m...
API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.m...
API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.m...
API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.m...
ACCESSORS =[ ,=,_before_type_cast,?,_changed?,_change,_will_change!,_was]Zombie Radar-FIELD HUNTINGFriday, May 10, 13
-def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define...
-def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define...
-def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define...
-def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define...
-def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define...
-def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define...
Friday, May 10, 13
class ApplicationControllerrescue_from DeprecatedAttributeError, :with => :log_deprecateprivatedef log_deprecated edepreca...
cmaruz/continuableclass ApplicationControllerrescue_from DeprecatedAttributeError, :with => :log_deprecateprivatedef log_d...
REFACTOR-Friday, May 10, 13
REFACTOR-DEPLOYFriday, May 10, 13
REFACTORNew Code-DEPLOYFriday, May 10, 13
REFACTORMigrationNew Code-DEPLOYFriday, May 10, 13
REFACTORMigrationNew Code-DEPLOYFriday, May 10, 13
WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234-TimeIn CacheFriday, May 10, 13
WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deploy-TimeIn CacheFriday, May 10, 13
WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number...
WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number...
WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number...
WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number...
IGNORE COLUMNS-class Userdef columnsself.class.columns.reject do |c|(self.class.deprecated_attributes || []).include? c.na...
THANK YOU !!https://github.com/yarmand/acreadAcread-Friday, May 10, 13
Upcoming SlideShare
Loading in …5
×

Deprecating ActiveRecord Attributes without making Zombies

640 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
640
On SlideShare
0
From Embeds
0
Number of Embeds
37
Actions
Shares
0
Downloads
2
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Deprecating ActiveRecord Attributes without making Zombies

  1. 1. -Friday, May 10, 13
  2. 2. YANN ARMAND-@yarmandFriday, May 10, 13
  3. 3. -The Enterprise Social NetworkFriday, May 10, 13
  4. 4. Friday, May 10, 13
  5. 5. DELETE A DB COLUMNWITHOUT MAKING ZOMBIESFriday, May 10, 13
  6. 6. DELETE A DB COLUMNWITHOUT MAKING ZOMBIESFriday, May 10, 13
  7. 7. WHY DELETE A MODELATTRIBUTE ?-Friday, May 10, 13
  8. 8. WHY DELETE A MODELATTRIBUTE ?• Not used anymore-Friday, May 10, 13
  9. 9. WHY DELETE A MODELATTRIBUTE ?• Not used anymoreUser Payment card• card_type• card_number• Move to another model-Friday, May 10, 13
  10. 10. KILLING AN ACTIVE RECORDFIELDCons-Friday, May 10, 13
  11. 11. KILLING AN ACTIVE RECORDFIELD• Code dependencyCons-Friday, May 10, 13
  12. 12. KILLING AN ACTIVE RECORDFIELD• Code dependencyCons• Unknown impact on the app behavior-Friday, May 10, 13
  13. 13. KILLING AN ACTIVE RECORDFIELD• Code dependencyCons• Unknown impact on the app behavior-Friday, May 10, 13
  14. 14. KILLING AN ACTIVE RECORDFIELD• Code dependencyCons• Unknown impact on the app behavior-Friday, May 10, 13
  15. 15. KILL AN ACTIVE RECORDFIELDPros-Friday, May 10, 13
  16. 16. KILL AN ACTIVE RECORDFIELDPros• ReduceTechnical Debt-Friday, May 10, 13
  17. 17. KILL AN ACTIVE RECORDFIELDPros• ReduceTechnical Debt• Smaller code base• Lower barrier of entry-• Eliminate black holes• Prevent crashesFriday, May 10, 13
  18. 18. BE PREPARED !!-Friday, May 10, 13
  19. 19. BE PREPARED !!-Friday, May 10, 13
  20. 20. BE PREPARED !!-Friday, May 10, 13
  21. 21. class Userdeprecate_attribute :card_typedeprecate_attribute :card_numberend-Friday, May 10, 13
  22. 22. API OUTPUTrender :json => username: rogerage: 23card_type: visacard_number: 123412341234name: rogerage: 23-Friday, May 10, 13
  23. 23. API OUTPUTrender :json => username: rogerage: 23card_type: visacard_number: 123412341234name: rogerage: 23-ActiveRecord#serializable_hashFriday, May 10, 13
  24. 24. API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.merge! {:only => self.attributes.keys.map(&:to_sym) -(self.class.deprecated_attributes ||[]).map(&:to_sym)}super_serializable_hash(options)endendFriday, May 10, 13
  25. 25. API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.merge! {:only => self.attributes.keys.map(&:to_sym) -(self.class.deprecated_attributes ||[]).map(&:to_sym)}super_serializable_hash(options)endendFriday, May 10, 13
  26. 26. API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.merge! {:only => self.attributes.keys.map(&:to_sym) -(self.class.deprecated_attributes ||[]).map(&:to_sym)}super_serializable_hash(options)endendFriday, May 10, 13
  27. 27. API OUTPUT-class Useralias_method :super_serializable_hash, :serializable_hashdef serializable_hash(options = {})options.merge! {:only => self.attributes.keys.map(&:to_sym) -(self.class.deprecated_attributes ||[]).map(&:to_sym)}super_serializable_hash(options)endendFriday, May 10, 13
  28. 28. ACCESSORS =[ ,=,_before_type_cast,?,_changed?,_change,_will_change!,_was]Zombie Radar-FIELD HUNTINGFriday, May 10, 13
  29. 29. -def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define_method("#{attr}#{term}") do |*args|raise DeprecatedAttributeError, msgsuperendendendFriday, May 10, 13
  30. 30. -def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define_method("#{attr}#{term}") do |*args|raise DeprecatedAttributeError, msgsuperendendendFriday, May 10, 13
  31. 31. -def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define_method("#{attr}#{term}") do |*args|raise DeprecatedAttributeError, msgsuperendendendFriday, May 10, 13
  32. 32. -def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define_method("#{attr}#{term}") do |*args|raise DeprecatedAttributeError, msgsuperendendendFriday, May 10, 13
  33. 33. -def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define_method("#{attr}#{term}") do |*args|raise DeprecatedAttributeError, msgsuperendendendFriday, May 10, 13
  34. 34. -def deprecate_attribute attrmsg = "You cant access atribute #{attr}, it has beendeprecated"ACCESSORS.each do |term|define_method("#{attr}#{term}") do |*args|raise DeprecatedAttributeError, msgsuperendendendFriday, May 10, 13
  35. 35. Friday, May 10, 13
  36. 36. class ApplicationControllerrescue_from DeprecatedAttributeError, :with => :log_deprecateprivatedef log_deprecated edeprecated_logger.error(e.backtrace.join("n"))e.continueendendFriday, May 10, 13
  37. 37. cmaruz/continuableclass ApplicationControllerrescue_from DeprecatedAttributeError, :with => :log_deprecateprivatedef log_deprecated edeprecated_logger.error(e.backtrace.join("n"))e.continueendendFriday, May 10, 13
  38. 38. REFACTOR-Friday, May 10, 13
  39. 39. REFACTOR-DEPLOYFriday, May 10, 13
  40. 40. REFACTORNew Code-DEPLOYFriday, May 10, 13
  41. 41. REFACTORMigrationNew Code-DEPLOYFriday, May 10, 13
  42. 42. REFACTORMigrationNew Code-DEPLOYFriday, May 10, 13
  43. 43. WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234-TimeIn CacheFriday, May 10, 13
  44. 44. WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deploy-TimeIn CacheFriday, May 10, 13
  45. 45. WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number: 123412341234-TimeIn Cache UpdateFriday, May 10, 13
  46. 46. WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number: 123412341234Save-TimeIn Cache UpdateFriday, May 10, 13
  47. 47. WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number: 123412341234SaveDatabase Exceptionunknown columnscard_type, card_number-TimeIn Cache UpdateFriday, May 10, 13
  48. 48. WHAT HAPPENS ?name: rogerage: 23card_type: visacard_number: 123412341234Deployname: rogerage: 24card_type: visacard_number: 123412341234SaveDatabase Exceptionunknown columnscard_type, card_number-TimeIn Cache UpdateFriday, May 10, 13
  49. 49. IGNORE COLUMNS-class Userdef columnsself.class.columns.reject do |c|(self.class.deprecated_attributes || []).include? c.name.to_sendendendFriday, May 10, 13
  50. 50. THANK YOU !!https://github.com/yarmand/acreadAcread-Friday, May 10, 13

×