@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end # 21 more lines def tick if name != 'Aged Brie' && name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end end 6 Thursday, April 24, 14
22 previous lines if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end def tick if name != 'Aged Brie' && name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end end 7 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 8 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 44.7 0 25 50 big conditional Complexity (Flog) 9 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 44.7 0 25 50 big conditional Complexity (Flog) 50 9 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 44.7 0 25 50 big conditional Complexity (Flog) 45 tick 50 9 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 10 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 12 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end Squint Test 12 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end changes in shape 13 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 2 14 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end changes in color 15 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 16 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 17 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 16 if statements 17 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 16 if statements 7 != 17 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 16 if statements 7 != 2 != with && 17 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 16 if statements 7 != 2 != with && 3 magic strings 17 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end 16 if statements 7 != 2 != with && 3 magic strings ? magic numbers 17 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end magic strings 18 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end ‘Aged Brie’ magic strings 18 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end ‘Aged Brie’ ‘Sulfuras, Hand of Ragnaros’ magic strings 18 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end ‘Aged Brie’ ‘Sulfuras, Hand of Ragnaros’ ‘Backstage passes to a TAFKAL80ETC concert’ magic strings 18 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end it has tests 19 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end # .... def tick if name != 'Aged Brie' && name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end end 34 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end # .... def tick if name != 'Aged Brie' && name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end end 34 Thursday, April 24, 14
@name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end def tick if name == 'normal' return end if name != 'Aged Brie' && name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end end 35 Thursday, April 24, 14
name == 'normal' return end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end def tick if name == 'normal' return end if name != 'Aged Brie' && name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end end 36 Thursday, April 24, 14
if name == 'normal' return end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' # ... 40 more lines end end 38 Thursday, April 24, 14
if name == 'normal' return end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' # ... 40 more lines end def normal_tick end end 39 Thursday, April 24, 14
if name == 'normal' return normal_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' # ... 40 more lines end def normal_tick end end 40 Thursday, April 24, 14
= GildedRose.new('normal', 10, 5) item.tick assert_equal 9, item.quality assert_equal 4, item.days_remaining end class GildedRose # ... def normal_tick end end 43 Thursday, April 24, 14
= GildedRose.new('normal', 10, 5) item.tick assert_equal 9, item.quality assert_equal 4, item.days_remaining end class GildedRose # ... def normal_tick end end 43 Thursday, April 24, 14
= GildedRose.new('normal', 10, 0) item.tick assert_equal 8, item.quality assert_equal -‐1, item.days_remaining end class GildedRose # ... def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end @days_remaining -‐= 1 end end 49 Thursday, April 24, 14
= GildedRose.new('normal', 0, 5) item.tick assert_equal 0, item.quality assert_equal 4, item.days_remaining end class GildedRose # ... def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end @days_remaining -‐= 1 end end 51 Thursday, April 24, 14
= GildedRose.new('normal', 0, 5) item.tick assert_equal 0, item.quality assert_equal 4, item.days_remaining end class GildedRose # ... def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end @days_remaining -‐= 1 end end 51 Thursday, April 24, 14
= GildedRose.new('normal', 0, 5) item.tick assert_equal 0, item.quality assert_equal 4, item.days_remaining end class GildedRose # ... def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end @days_remaining -‐= 1 end end 51 Thursday, April 24, 14
= GildedRose.new('normal', 0, 5) item.tick assert_equal 0, item.quality assert_equal 4, item.days_remaining end class GildedRose # ... def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end @days_remaining -‐= 1 end end 52 Thursday, April 24, 14
= GildedRose.new('normal', 0, 5) item.tick assert_equal 0, item.quality assert_equal 4, item.days_remaining end class GildedRose # ... def normal_tick if @quality != 0 if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end @days_remaining -‐= 1 end end 53 Thursday, April 24, 14
@quality != 0 if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end @days_remaining -‐= 1 end 57 Thursday, April 24, 14
normal_tick if @quality != 0 if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end @days_remaining -‐= 1 end 58 Thursday, April 24, 14
-‐= 1 end def normal_tick if @quality != 0 if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end @days_remaining -‐= 1 end 59 Thursday, April 24, 14
-‐= 1 end def normal_tick if @quality != 0 if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end end 60 Thursday, April 24, 14
-‐= 1 return if @quality == 0 end def normal_tick if @quality != 0 if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end end 61 Thursday, April 24, 14
-‐= 1 return if @quality == 0 end def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end 62 Thursday, April 24, 14
-‐= 1 return if @quality == 0 @quality -‐= 1 end def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end 63 Thursday, April 24, 14
-‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def normal_tick if @days_remaining > 0 @quality -‐= 1 end if @days_remaining <= 0 @quality -‐= 2 end end 64 Thursday, April 24, 14
if name == 'normal' return normal_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' # ... 40 more lines end end Reprise 68 Thursday, April 24, 14
if name == 'normal' return normal_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' # ... 40 more lines end end 69 Thursday, April 24, 14
if name == 'normal' return normal_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' # ... 40 more lines end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end end 70 Thursday, April 24, 14
if name == 'normal' return normal_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' # ... 40 more lines end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end end normal 70 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick end # ... end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end 78 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick end # ... end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end brie 78 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick end # ... end def sulfuras_tick end 84 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick end # ... end def sulfuras_tick end 86 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick end # ... end def sulfuras_tick end nothing changes 86 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick end # ... end def sulfuras_tick end sulfuras 86 Thursday, April 24, 14
name when 'normal' when 'Aged Brie' when 'Sulfuras, Hand of Ragnaros' when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end # ... end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end backstage 88 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c # ... end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick def sulfuras_tick def backstage_tick class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remai end def tick case name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if name != 'Aged Brie' && name != 'Backstage passes to a TAF if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 90 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c # ... end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick def sulfuras_tick def backstage_tick class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remai end def tick case name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if name != 'Aged Brie' && name != 'Backstage passes to a TAF if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 90 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c # ... end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick def sulfuras_tick def backstage_tick class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remai end def tick case name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if name != 'Aged Brie' && name != 'Backstage passes to a TAF if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 90 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c # ... end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick def sulfuras_tick def backstage_tick class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remai end def tick case name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if name != 'Aged Brie' && name != 'Backstage passes to a TAF if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 90 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c # ... end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick def sulfuras_tick def backstage_tick class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remai end def tick case name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if name != 'Aged Brie' && name != 'Backstage passes to a TAF if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 90 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c # ... end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick def sulfuras_tick def backstage_tick class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remai end def tick case name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if name != 'Aged Brie' && name != 'Backstage passes to a TAF if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 90 Thursday, April 24, 14
name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC c # ... end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick def sulfuras_tick def backstage_tick class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remai end def tick case name when 'normal' return normal_tick when 'Aged Brie' return brie_tick when 'Sulfuras, Hand of Ragnaros' return sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' return backstage_tick end if name != 'Aged Brie' && name != 'Backstage passes to a TAF if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if quality < 50 @quality += 1 if name == 'Backstage passes to a TAFKAL80ETC concert' if days_remaining < 11 if quality < 50 @quality += 1 end end if days_remaining < 6 if quality < 50 @quality += 1 end end end end end if name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if days_remaining < 0 if name != "Aged Brie" if name != 'Backstage passes to a TAFKAL80ETC concert' if quality > 0 if name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = quality -‐ quality end else if quality < 50 @quality += 1 end end end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 90 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end small methods 93 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end end big conditional small methods 94 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 0 25 50 big conditional Total Complexity 50 95 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 0 25 50 big conditional small methods tick normal brie backstage other 40 Total Complexity 50 96 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 0 25 50 big conditional small methods tick normal brie backstage other 12 40 45 Total Complexity 50 96 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end Complexity 50 big conditional 97 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 0 45 90 Complexity 50 big conditional 97 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 0 45 90 Complexity 50 84 40 small methods big conditional 10 Refactorings 97 Thursday, April 24, 14
end class Normal attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end end 123 Thursday, April 24, 14
@days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end class Brie def tick end end 138 Thursday, April 24, 14
class Brie def tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end end 139 Thursday, April 24, 14
class Sulfuras attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end 144 Thursday, April 24, 14
class Sulfuras attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end 145 Thursday, April 24, 14
@item = Sulfuras.new(quality, days_remaining) item.tick end class Sulfuras attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end 146 Thursday, April 24, 14
case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @item = Normal.new(quality, days_remaining) item.tick end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 157 Thursday, April 24, 14
case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @item = Normal.new(quality, days_remaining) item.tick end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 159 Thursday, April 24, 14
case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @item = Normal.new(quality, days_remaining) item.tick end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 160 Thursday, April 24, 14
case name when 'normal' when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @item = Normal.new(quality, days_remaining) item.tick end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 161 Thursday, April 24, 14
case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 162 Thursday, April 24, 14
case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 163 Thursday, April 24, 14
case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 164 Thursday, April 24, 14
case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' when 'Sulfuras, Hand of Ragnaros' when 'Backstage passes to a TAFKAL80ETC concert' end end def brie_tick @item = Brie.new(quality, days_remaining) item.tick end # etc 165 Thursday, April 24, 14
case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 166 Thursday, April 24, 14
case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 168 Thursday, April 24, 14
case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 169 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 170 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 170 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = ??? end def tick case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 171 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = ??? end def tick case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 171 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = ???.new(quality, days_remaining) end def tick case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 172 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = ???.new(quality, days_remaining) end def tick case name when 'normal' @item = Normal.new(quality, days_remaining) item.tick when 'Aged Brie' @item = Brie.new(quality, days_remaining) item.tick when 'Sulfuras, Hand of Ragnaros' @item = Sulfuras.new(quality, days_remaining) item.tick when 'Backstage passes to a TAFKAL80ETC concert' @item = Backstage.new(quality, days_remaining) item.tick end end 172 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = ???.new(quality, days_remaining) end def case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end 173 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = ???.new(quality, days_remaining) end def case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 174 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = ???.new(quality, days_remaining) end def klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 175 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 176 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 176 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 177 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality return item.quality if item @quality end def days_remaining return item.days_remaining if item @days_remaining end 180 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality return item.quality if item @quality end def days_remaining return item.days_remaining if item @days_remaining end 180 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality return item.quality if item end def days_remaining return item.days_remaining if item end 181 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality return item.quality if item end def days_remaining return item.days_remaining if item end 181 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality return item.quality if item end def days_remaining return item.days_remaining if item end 181 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end 182 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 183 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 192 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 192 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 193 Thursday, April 24, 14
initialize(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 193 Thursday, April 24, 14
self.for(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 194 Thursday, April 24, 14
self.for(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 194 Thursday, April 24, 14
self.for(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 195 Thursday, April 24, 14
self.for(name, quality, days_remaining) @item = klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 195 Thursday, April 24, 14
self.for(name, quality, days_remaining) klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 196 Thursday, April 24, 14
self.for(name, quality, days_remaining) klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 196 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 197 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 198 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end 198 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end Middleman 198 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end def tick item.tick end def quality item.quality end def days_remaining item.days_remaining end class Normal class Brie class Sulfuras class Backstage end Middleman 198 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end class Normal class Brie class Sulfuras class Backstage end 199 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end class Normal class Brie class Sulfuras class Backstage end 203 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) # ... end class Normal class Brie class Sulfuras class Backstage end 203 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal def tick # ... end end class Brie attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick 208 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick 209 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick # ... end end 210 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick # ... end end 211 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end 212 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end class Backstage < Item def tick 213 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end class Backstage < Item def tick 216 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end class Backstage < Item def tick Item quality days_remaining 216 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end class Backstage < Item def tick Item quality days_remaining Normal Brie Sulfuras Backstage quality days_remaining tick 216 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end class Backstage < Item def tick Item quality days_remaining Normal Brie Sulfuras Backstage quality days_remaining tick 216 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end 217 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end 218 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end class Normal < Item def tick # ... end end class Brie < Item def tick # ... end end class Sulfuras < Item def tick end end 218 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end class Sulfuras < Item def tick end end 219 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end class Sulfuras < Item def tick end end 219 Thursday, April 24, 14
def tick end end class Sulfuras < Item def tick end end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 221 Thursday, April 24, 14
def tick end end class Sulfuras < Item def tick end end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Sulfuras when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 221 Thursday, April 24, 14
def tick end end class Sulfuras < Item def tick end end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 222 Thursday, April 24, 14
def tick end end class Sulfuras < Item def tick end end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 222 Thursday, April 24, 14
def tick end end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 223 Thursday, April 24, 14
def tick end end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 224 Thursday, April 24, 14
def tick end end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end 225 Thursday, April 24, 14
klass_for(name).new(quality, days_remaining) end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end end 227 Thursday, April 24, 14
SPECIALIZED_CLASSES = { 'normal' => Normal, 'Aged Brie' => Brie, 'Backstage passes to a TAFKAL80ETC concert' => Backstage } def self.for(name, quality, days_remaining) klass_for(name).new(quality, days_remaining) end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end end 228 Thursday, April 24, 14
SPECIALIZED_CLASSES = { 'normal' => Normal, 'Aged Brie' => Brie, 'Backstage passes to a TAFKAL80ETC concert' => Backstage } def self.for(name, quality, days_remaining) klass_for(name).new(quality, days_remaining) end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end end 229 Thursday, April 24, 14
SPECIALIZED_CLASSES = { 'normal' => Normal, 'Aged Brie' => Brie, 'Backstage passes to a TAFKAL80ETC concert' => Backstage } def self.for(name, quality, days_remaining) klass_for(name). new(quality, days_remaining) end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end end 230 Thursday, April 24, 14
SPECIALIZED_CLASSES = { 'normal' => Normal, 'Aged Brie' => Brie, 'Backstage passes to a TAFKAL80ETC concert' => Backstage } def self.for(name, quality, days_remaining) (SPECIALIZED_CLASSES[name] || DEFAULT_CLASS). new(quality, days_remaining) end def self.klass_for(name) case name when 'normal' Normal when 'Aged Brie' Brie when 'Sulfuras, Hand of Ragnaros' Item when 'Backstage passes to a TAFKAL80ETC concert' Backstage end end end 231 Thursday, April 24, 14
attr_reader :quality, :days_remaining def initialize(quality, days_remaining) @quality, @days_remaining = quality, days_remaining end def tick end end class Normal < Item def tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end end class Brie < Item def tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end end class Backstage < Item def tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end DEFAULT_CLASS = Item SPECIALIZED_CLASSES = { 'normal' => Normal, 'Aged Brie' => Brie, 'Backstage passes to a TAFKAL80ETC concert' => Backstage } def self.for(name, quality, days_remaining) (SPECIALIZED_CLASSES[name] || DEFAULT_CLASS).new(quality, days_remainin end end small objects class GildedRose attr_reader :name, :quality, :days_remaining def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else if @quality < 50 @quality += 1 if @name == 'Backstage passes to a TAFKAL80ETC concert' if @days_remaining < 11 if @quality < 50 @quality += 1 end end if @days_remaining < 6 if @quality < 50 @quality += 1 end end end end end if @name != 'Sulfuras, Hand of Ragnaros' @days_remaining -‐= 1 end if @days_remaining < 0 if @name != "Aged Brie" if @name != 'Backstage passes to a TAFKAL80ETC concert' if @quality > 0 if @name != 'Sulfuras, Hand of Ragnaros' @quality -‐= 1 end end else @quality = @quality -‐ @quality end else if @quality < 50 @quality += 1 end end end end end big conditional 238 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end big conditional small methods small objects 50 84 40 Total Complexity 242 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 0 45 90 big conditional small methods small objects 50 84 40 Total Complexity 242 Thursday, April 24, 14
def initialize(name, quality, days_remaining) @name, @quality, @days_remaining = name, quality, days_remaining end def tick case name when 'normal' normal_tick when 'Aged Brie' brie_tick when 'Sulfuras, Hand of Ragnaros' sulfuras_tick when 'Backstage passes to a TAFKAL80ETC concert' backstage_tick end end def normal_tick @days_remaining -‐= 1 return if @quality == 0 @quality -‐= 1 @quality -‐= 1 if @days_remaining <= 0 end def brie_tick @days_remaining -‐= 1 return if @quality >= 50 @quality += 1 @quality += 1 if @days_remaining <= 0 end def sulfuras_tick end def backstage_tick @days_remaining -‐= 1 return if @quality >= 50 return @quality = 0 if @days_remaining < 0 @quality += 1 @quality += 1 if @days_remaining < 10 @quality += 1 if @days_remaining < 5 end end 0 45 90 big conditional small methods small objects 50 84 40 33 86 Total Complexity 242 Thursday, April 24, 14