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

Code smells & Refactoring

Code smells & Refactoring

Code smells are certain lines in the code that indicate a violation of fundamental design principles and negatively impact design quality. We will be discussing different types of code smells and refactoring techniques to remove those smells.

AndiGeeky

April 02, 2017
Tweet

More Decks by AndiGeeky

Other Decks in Technology

Transcript

  1. Code Smell are certain structures in the code that indicate

    violation of fundamental design principles and negatively impact design quality. Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.
  2. “A code smell is a surface indication that usually corresponds

    to a deeper problem in the system” - Martin Flower
  3. Design Principles Every OO Designer should have follow below design

    principle, failing to that leads to code smells in your software. Design Principles: - Single Responsibility - Open Close principle - Interface Segregation - Dependency Inversion principle - Liskov Substitution principle
  4. Levels of Code smell There are three levels of code

    smell: 1. Method level 2. Class level 3. Application level
  5. Bad smells in a code Long Method - Extract method

    Long class - Extract Class Long parameter list - Introduce Object parameter Primitive Obsession - Introduce Object parameter Duplicate Code (Don’t Repeat Yourself) - Create Template method
  6. Speculative Generality Oh! We might need this feature in future

    Remedy: - Collapse Hierarchy - Inline class - Remove Parameter
  7. Thanks! Software Engineer, Mastercard Transaction solution pvt. Ltd., Vadodara -

    Gujarat AndiGeeky @MamataGelanee andigeeky.wordpress.com/ mamatagelanee07