is misunderstood steven solomon
play

IS MISUNDERSTOOD Steven Solomon Senior Software Engineer @ Pivotal - PowerPoint PPT Presentation

THE DRY PRINCIPLE IS MISUNDERSTOOD Steven Solomon Senior Software Engineer @ Pivotal Labs Twitter: @ssolo112 Medium: @ssolomon DRY PRINCIPLE GROCERY APPLICATION By Annie Spratt on Unsplash WHAT IS IN THE APPLICATION? Dry Goods Produce


  1. DIVERGENT CHANGE # priceable.rb module Priceable def price psychological_price( @cost * @margin ) end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  2. DIVERGENT CHANGE # priceable.rb Steak prices are based on cut module Priceable def price psychological_price( @cost * @margin ) end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  3. DIVERGENT CHANGE # priceable.rb module Priceable Steak prices are based on cut def price total += psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  4. DIVERGENT CHANGE # priceable.rb module Priceable def price total += psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  5. DIVERGENT CHANGE # priceable.rb Produce prices are based on season module Priceable def price total += psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  6. DIVERGENT CHANGE # priceable.rb Produce prices are based on season module Priceable def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  7. DIVERGENT CHANGE # priceable.rb module Priceable def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  8. Shotgun Divergent Surgery Change

  9. NOTICING DIVERGENT CHANGE

  10. TECHNIQUES

  11. GETTING BACK TO SAFETY

  12. class Produce include Priceable def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end end

  13. class Produce include Priceable def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end end

  14. class Produce include Priceable def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end end

  15. class Produce def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end def price(season = nil) total = psychological_price(@price * @margin) if @type == :steak && @cut == :flatiron total + BigDecimal('5') else season != @growing_season ? total + 1 : total end end private def psychological_price(amount) if amount.ceil == amount (amount + BigDecimal('0.50')).ceil - BigDecimal('0.01') else (amount).ceil - BigDecimal('0.01') end end end

  16. class Produce def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end def price(season = nil) total = psychological_price(@cost * @margin) if @type == :steak && @cut == :flatiron total + BigDecimal('5') else season != @growing_season ? total + 1 : total end end private def psychological_price(amount) if amount.ceil == amount (amount + BigDecimal('0.50')).ceil - BigDecimal('0.01') else (amount).ceil - BigDecimal('0.01') end end end

  17. class Produce def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end def price(season = nil) total = psychological_price(@cost * @margin) if @type == :steak && @cut == :flatiron total + BigDecimal('5') else season != @growing_season ? total + 1 : total end end private def psychological_price(amount) if amount.ceil == amount (amount + BigDecimal('0.50')).ceil - BigDecimal('0.01') else (amount).ceil - BigDecimal('0.01') end end end

  18. class Produce def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end def price(season = nil) total = psychological_price(@cost * @margin) if @type == :steak && @cut == :flatiron total + BigDecimal('5') else season != @growing_season ? total + 1 : total end end private def psychological_price(amount) if amount.ceil == amount (amount + BigDecimal('0.50')).ceil - BigDecimal('0.01') else (amount).ceil - BigDecimal('0.01') end end end

  19. class Produce def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end def price(season = nil) total = psychological_price(@cost * @margin) if @type == :steak && @cut == :flatiron total + BigDecimal('5') else season != @growing_season ? total + 1 : total end end private def psychological_price(amount) if amount.ceil == amount (amount + BigDecimal('0.50')).ceil - BigDecimal('0.01') else (amount).ceil - BigDecimal('0.01') end end end

  20. class Produce def initialize ( cost , growing_season ) @cost = cost @growing_season = growing_season @margin = BigDecimal ( '100' ) end def price(season = nil) total = psychological_price(@cost * @margin) season != @growing_season ? total + 1 : total end private def psychological_price(amount) if amount.ceil == amount (amount + BigDecimal('0.50')).ceil - BigDecimal('0.01') else (amount).ceil - BigDecimal('0.01') end end end

  21. class DryGood include Priceable def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end end

  22. class DryGood include Priceable def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end end

  23. class DryGood include Priceable def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end end

  24. class DryGood def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end def price ( season = nil ) total = psychological_price( @price * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  25. class DryGood def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  26. class DryGood def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  27. class DryGood def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  28. class DryGood def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end def price () total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  29. class DryGood def initialize ( cost ) @cost = cost @margin = BigDecimal ( '200' ) end def price () psychological_price( @cost * @margin ) end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  30. class Meat include Priceable def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end end

  31. class Meat include Priceable def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end end

  32. class Meat include Priceable def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end end

  33. class Meat def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end def price ( season = nil ) total = psychological_price( @price * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  34. class Meat def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  35. class Meat def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  36. class Meat def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end def price (season = nil) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  37. class Meat def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end def price () total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  38. class Meat def initialize ( cost , type , cut ) @cost = cost @type = type @cut = cut @margin = BigDecimal ( '300' ) end def price () total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  39. module Priceable def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

  40. module Priceable def price ( season = nil ) total = psychological_price( @cost * @margin ) if @type == :steak && @cut == :flatiron total + BigDecimal ( '5' ) else season != @growing_season ? total + 1 : total end end private def psychological_price ( amount ) if amount .ceil == amount ( amount + BigDecimal ( '0.50' )).ceil - BigDecimal ( '0.01' ) else ( amount ).ceil - BigDecimal ( '0.01' ) end end end

Recommend


More recommend