# 5 Lições de Design Orientado a Objetos da Sandi Metz

Esta é uma tradução do artigo escrito por Jessie Young e publicado em: https://18f.gsa.gov/2016/06/24/5-lessons-in-object-oriented-design-from-sandi-metz/

# 2. Busque o verde mais fácil de alcançar

`class Bottles  def verse(number)    if number - 1 == 0      next_number = "no more"    else      next_number = number - 1    end    if number - 1 == 1      next_bottle = "bottle"    else      next_bottle = "bottles"    end    if number == 1      bottle = "#{number} bottle"    elsif number == 0      bottle = "no more bottles"    else      bottle = "#{number} bottles"    end    if number == 1      pronoun = "it"    else      pronoun = "one"    end    if number == 0      second_verse = "Go to the store and buy some more, " +      "99 bottles of beer on the wall.\n"    else      second_verse = "Take #{pronoun} down and pass it around, " +      "#{next_number} #{next_bottle} of beer on the wall.\n"    end    "#{bottle.capitalize} of beer on the wall, " +      "#{bottle} of beer.\n" +      second_verse  endend`
`class Bottles  def verse(number)    case number    when 0      "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"    when 1      "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n"    when 2      "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n"    else      "#{number} bottles of beer on the wall, #{number} bottles of beer.\nTake one down and pass it around, #{number-1} bottles of beer on the wall.\n"    end  endend`

# 5. Escreva o melhor código possível hoje, seja completamente desapegado dele e esteja disposto a apagá-lo amanhã

--

--

Software development nerd. In 💙 with Ruby, PHP, JavaScript, Crystal, and other techy stuff.

Love podcasts or audiobooks? Learn on the go with our new app.

## Alan Willms

Software development nerd. In 💙 with Ruby, PHP, JavaScript, Crystal, and other techy stuff.