1 / 7

Code Smells

Code Smells. As You Arrive… Please snarf the code for today Please get a packet from near the entrance. Why “smells”?. You are responsible for knowing all of these. Duplicate code Long Method Large Class Long Parameter List Divergent Change Shotgun Surgery Feature Envy Data Clumps

adonai
Télécharger la présentation

Code Smells

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Code Smells As You Arrive… Please snarf the code for today Please get a packet from near the entrance

  2. Why “smells”?

  3. You are responsible for knowing all of these. Duplicate code Long Method Large Class Long Parameter List Divergent Change Shotgun Surgery Feature Envy Data Clumps Primitive Obsession Switch Statements Refused Bequest Parallel Inheritance Hierarchies Lazy Class Speculative Generality Temporary Field Message Chains Inappropriate Intimacy Alternative Classes with Different Interfaces Incomplete Library Classes Data Class Comments

  4. A Few Commonalities The Bloaters Long Method Large Class Invisible Classes Primitive Obsession Long Parameter list Data Clumps The Couplers Feature Envy Inappropriate Intimacy Message Chains Simplistic Classes Lazy Class Data Class Middle Man Worst Thing in the World Duplicated Code Problematic Classes Temporary Field Refused Bequest Alternative Classes With Different Interfaces Parallel Class Hierarchies Change Preventers Divergent Change Shotgun Surgery

  5. 4 Smells for Today • Comments • Feature Envy • Data Class • Long Parameter List

  6. Fixing Bad Smells Using Refactoring Tools

  7. Fix the Bad Code Smells • Comments in Matcher.java • Feature Envy in Report.java • Data Class in Person.java • Long Parameter List (just read the packet and answer the questions) • When you’re finished the test cases should still run • Submit via Ambient

More Related