Fighting code smells

12
Fighting code smells Patterns to keep your code DRY

description

Follow us on : Facebook: https://www.facebook.com/siliconstraitssaigon Website: http://www.siliconstraits.vn/ Blog: http://blog.siliconstraits.vn/

Transcript of Fighting code smells

Page 1: Fighting code smells

Fighting code smellsPatterns to keep your code DRY

Page 2: Fighting code smells

Code smells• Warning signs in the code which indicate

weaknesses in design.

=> slow down development and increase risk of bugs in future.

Page 3: Fighting code smells

Code smells• Duplicated Code

Page 4: Fighting code smells

Code smells• Long Method

Page 5: Fighting code smells

Code smells• Feature Envy

Page 6: Fighting code smells

Code smells• Data clumps

Page 7: Fighting code smells

Code smells• Message chains

Page 8: Fighting code smells

Code smells• Divergent change

Page 9: Fighting code smells

Refactoring Patterns• Extract Method

• Pull up Method

• Form Template Method

• Replace Method with Method Object

• Extract Class

Page 10: Fighting code smells

Refactoring Patterns• Demo: http://goo.gl/zpouEN

Page 11: Fighting code smells

Read more…• Refactoring: Improving Design of Existing Code - by

Martin Flower

• Refactoring: Ruby Edition - by Jay Fields, Shane Harvie, Martin Flower and Kent Beck

• http://ghendry.net/refactor.html

• http://sourcemaking.com/refactoring

• Reek: Code smells detector - https://github.com/troessner/reek

Page 12: Fighting code smells

About @Vinh Bachsy• Author: Vinh Bachsy @: [email protected]

• You can follow me at:

• https://plus.google.com/+VinhBachsy

• https://www.facebook.com/vinh.bachsy

• And the Saigon.rb Meetup:

• http://www.meetup.com/saigon-rb/

• https://www.facebook.com/saigonrb