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

Broken Windows

Broken Windows

Why does a team of smart people end up with a messy code base over time? We use great technologies and methodologies, but the reason for the mess often comes down to human nature.

Broken Windows theory explains how seemingly little problems can provide the foundation for a future disaster. People often unconsciously don't fix things because they think it’s ok to keep it messy, but these "broken windows" can lead to a whole host of bigger issues in your code base.

This presentation shows how Broken Windows theory can be applied to Software Engineering. It shows how to deal with broken windows in our software, deliver value and keep programmers happy.

Presented on LA Ruby September UnConference Meetup
http://www.meetup.com/laruby/events/129338842/

Alexander Tamoykin

September 12, 2013
Tweet

More Decks by Alexander Tamoykin

Other Decks in Technology

Transcript

  1. Simplified Code Example class SWE < ActiveRecord::Base! has_many :registrations! !

    def go_to_conference! my_registration = registrations.find_by_swe_id id! my_registration.book! end! end
  2. How do we get there ? class SWE < ActiveRecord::Base!

    has_many :flights! has_many :registrations! ! def go_to_conference! my_flight = flights.find_by_swe_id id! my_flight.book! my_registration.book = registrations.find_by_swe_id id! my_registration.book! end! end
  3. Where do we stay ? class SWE < ActiveRecord::Base! has_many

    :flights! has_many :hotels! has_many :registrations! ! def go_to_conference! my_hotel = hotels.find_by_swe_id id! my_hotel.book! my_flight = flights.find_by_swe_id id! my_flight.book! my_registration = registrations.find_by_swe_id id! my_registration.book! end! end
  4. What if the conference is sold out ? class SWE

    < ActiveRecord::Base! has_many :flights! has_many :hotels! has_many :registrations! ! def go_to_conference! my_registration = registrations.find_by_swe_id id! ! if my_registration.book! my_hotel = hotels.find_by_swe_id id! my_hotel.book! my_flight = flights.find_by_swe_id id! my_flight.book! end! end! end
  5. What if there is no hotel ? class SWE <

    ActiveRecord::Base! has_many :flights! has_many :hotels! has_many :registrations! ! def go_to_conference! my_registration = registrations.find_by_swe_id id! if my_registration.book! my_hotel = hotels.find_by_swe_id id! if my_hotel.book! my_flight = flights.find_by_swe_id id! my_flight.book! end! end! end! end
  6. Is this easier to change ? class SWE < ActiveRecord::Base!

    …! def go_to_conference! register! book_hotel! book_flight! end! ! def book_flight! my_flight = flights.find_by_swe_id id! my_flight.book! end! ! def book_hotel! my_hotel = hotels.find_by_swe_id id! my_hotel.book! end! ! def register! my_registration = registrations.find_by_swe_id id! my_registration.book! end! end
  7. How did it happen ? class SWE < ActiveRecord::Base! has_many

    :flights! has_many :hotels! has_many :registrations! ! def go_to_conference! my_registration = registrations.find_by_swe_id id! if my_registration.book! my_hotel = hotels.find_by_swe_id id! if my_hotel.book! my_flight = flights.find_by_swe_id id! my_flight.book! end! end! end! end
  8. How • Identify a broken window • Refactor it •

    Track it • Come back and do it right • Leave a comment
  9. Concrete Examples • Write a missing test • Split a

    large class into smaller classes • Look at Code Climate • Delete dead code • Review a pull request • Take a fresh look tomorrow • Encourage your coworker to fix it • Incrementally refactor