Skip to content

Instantly share code, notes, and snippets.

@matheusazzi
Created January 17, 2018 01:42
Show Gist options
  • Save matheusazzi/e00cc02949943062ef607e2f8e6bc497 to your computer and use it in GitHub Desktop.
Save matheusazzi/e00cc02949943062ef607e2f8e6bc497 to your computer and use it in GitHub Desktop.

Code Smells

  • Long Method
  • Large Class
  • Feature Envy
  • Case/Switch Statement
  • High Fan-out
  • Shotgun Surgery
  • Divergent Change
  • Long Parameter List
  • Duplicated Code
  • Uncommunicative Name
  • Single Table Inheritance (STI)
  • Parallel Inheritance Hierarchies
  • Comments
  • Mixin
  • Callback

Solutions

  • Replace Conditional with Polymorphism
  • Replace conditional with Null Object
  • Extract method
  • Rename Method
  • Extract Class
  • Extract Value Object
  • Extract Decorator
  • Extract Partial
  • Extract Validator
  • Introduce Explaining Variable
  • Introduce Observer
  • Introduce Form Object
  • Introduce Parameter Object
  • Use class as Factory
  • Move method
  • Inline class
  • Inject dependencies
  • Replace Subclasses with Strategies
  • Replace mixin with composition
  • Replace Callback with Method
  • Use convention over configuration
  • Introduce Visitor

Principles

  • DRY
  • Single responsibility principle
  • Tell, Don’t Ask
  • Law of Demeter
  • Composition over inheritance
  • Open/closed principle
  • Dependency inversion principle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment