Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DRY Introduction

DRY Introduction

A short DRY introduction I gave at the 5th Israeli Software Craftsmanship meeting before the Serializer Kata

Aviv Ben-Yosef

March 24, 2012
Tweet

More Decks by Aviv Ben-Yosef

Other Decks in Programming

Transcript

  1. The 4 Rules of Simple Design • Runs all the

    tests • No duplication • Expresses developer intent • Minimizes the number of classes and methods
  2. Plain Old Duplication if @unparsed_geminstaller_output_flags flags = @unparsed_geminstaller_output_flags.split(',') flags.delete_if {|flag|

    flag == nil or flag == ''} flags.map! {|flag| flag.downcase} flags.sort! flags.uniq! flags.map! {|flag| flag.to_sym} geminstaller_output_valid = true flags.each do |flag| unless VALID_GEMINSTALLER_OUTPUT_FLAGS.include?(flag) @output = "Invalid geminstaller-output flag: #{flag}\n" geminstaller_output_valid = false end end @options[:geminstaller_output] = flags if geminstaller_output_valid end if @unparsed_rubygems_output_flags flags = @unparsed_rubygems_output_flags.split(',') flags.delete_if {|flag| flag == nil or flag == ''} flags.map! {|flag| flag.downcase} flags.sort! flags.uniq! flags.map! {|flag| flag.to_sym} rubygems_output_valid = true flags.each do |flag| unless VALID_RUBYGEMS_OUTPUT_FLAGS.include?(flag) @output = "Invalid rubygems-output flag: #{flag}\n" rubygems_output_valid = false end end @options[:rubygems_output] = flags if rubygems_output_valid end
  3. Let’s get it on! • The Serializer Kata http://bit.ly/KataDRY •

    Do not move to next step until code duplication ≤ 0