Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Refactoring tools for Perl code

781 views

Published on

Slides from presentation at Mojoconf. Discusses my Extract Method refactoring implementation for Perl.

Published in: Software, Technology
  • Be the first to comment

  • Be the first to like this

Refactoring tools for Perl code

  1. 1. REFACTORING TOOLS IN PERL
  2. 2. WHAT IS REFACTORING Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior
  3. 3. REFACTORING CATALOG • ▶Add Parameter • ▶Change Bidirectional Association to Unidirectional • ▶Change Reference to Value • ▶Change Unidirectional Association to Bidirectional • ▶Change Value to Reference • ▶Collapse Hierarchy Expression • ▶Consolidate Duplicate Conditional Fragments • ▶Decompose Conditional • ▶Duplicate Observed Data • ▶Dynamic Method Definition • ▶Eagerly Initialized Attribute
  4. 4. THE GOALS • Make code more readable and comprehensible • Eliminate duplication
  5. 5. WHY? • Lots of time is spent reading code • Bugs hide in obscure code • Duplication makes code rot • LEARNING!
  6. 6. START OUT BRAINDEAD, GET BETTER
  7. 7. TOOLS ?????
  8. 8. JAVA REFACTORING In Eclipse
  9. 9. JAVASCRIPT REFACTORING In WebStorm
  10. 10. PERL REFACTORING
  11. 11. PPIx::EditorTools • Supports Vim and Emacs • RenameVariable (safe renaming) • RenamePackageFromPath • IntroduceTemporaryVariable
  12. 12. My extensions • Supports Vim only • ExtractMethod • ConvertVarToAttribute
  13. 13. Why refactor long methods? • Readability—make the essential logic clear • Isolated testing • Isolated editing • Avoid comments getting out of sync
  14. 14. ARCHITECTURE Analyzer VariableSorter CodeGenerator CodeEditor
  15. 15. ANALYZER CLASSES
  16. 16. CURRENT STATUS • Mostly safe with “normal” code. • No fancy installation available • Use the README at https://github.com/dagfin nr/perl-extract-method
  17. 17. • dagfinn@startsiden.no • dagfinn@reiersol.com • Github, Twitter (theoretically): dagfinnr

×