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

Google I/O Extended: Refactoring Smelly Code

Google I/O Extended: Refactoring Smelly Code

Originally, this was intended to be a series of blogposts demoing smelly code and refactoring patterns that can be improved to reduce the number of WTFs in the code. Later became a tech talk with hands-on demos before presented at developer forums and 2015 Google I/O Extended in Colombo, Sri Lanka.

Kosala (Nuwan) Perera

May 01, 2016
Tweet

More Decks by Kosala (Nuwan) Perera

Other Decks in Programming

Transcript

  1. get some paper, put it in a typewriter, type FADE

    IN ... and keep typing - Peter Falk told to Paul Reiser
  2. A computer program is the most complicated thing on earth,

    second to a woman's brain - Marvin Silva
  3. Why do you have to care? - Understandability - Readability

    - Changeability - Extensibility - Maintainability
  4. How do you write bad code? - Rigid - Fragile

    - Immobility - Design debt : Technical debt by taking shortcuts? - Environment debt : Technical debt by not running build, test, and other tasks - Needless complexity - Needless repetition - Opacity
  5. How to practice? - Code kata - Pair programming -

    Design/Code reviews - Peer reviews
  6. What can you do TODAY? - Naming conventions - Methods

    - Design principles - Dependency injection - Encapsulate conditionals - Polymorphism to If/Else or Switch/Case - Exception over return codes
  7. Other things that go with it? - KISS - Boy

    scout rule - Root cause analysis - Following standard conventions - Class design principles
  8. When you are matured with these principles and patterns it

    will become difficult for you to think without those - KP