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

Enter Cookbook: refactoring under a microscope

Enter Cookbook: refactoring under a microscope

Solutions for refactoring.

Kamil Samigullin

April 28, 2016
Tweet

More Decks by Kamil Samigullin

Other Decks in Education

Transcript

  1. • following the best practices (SOLID, DRY, etc.) • converting

    to a unified code style (PSR, etc.) • reducing algorithmic complexity (KISS, etc.) The main target of refactoring is increase code quality by
  2. • resistance to modifications • improving maintainability • internal satisfaction

    of a team The main benefits of increasing code quality are
  3. • reduction of errors and misprints due to a built-in

    code analyzer and autocompletion • increase in productivity through powerful features for refactoring Solved problems by using IDE
  4. • PhpStorm for PHP projects • WebStorm for front-end and

    Node.js projects • PyCharm for DevOps tools (SaltStack, Fabric) • IntelliJ IDEA for our ESB (based on ServiceMix) Products that we are using
  5. • knowledge transfer about the task • the division of

    responsibility • quality control of coding • sharing of experience Solved problems through code review
  6. • GitHub, our choice (+ Gogs as failover mirror) •

    Bitbucket • GitLab • Upsource Services that I have tried
  7. • exclusion parser errors of interpreted languages through static code

    analysis • prevent regression of functionality by applying unit and integration tests • collection of codebase quality metrics Solved problems by using CI
  8. • works on Jenkins • all configurations (for PHP and

    Node.js projects) in one repository • a role in refactoring is static analysis and collection of code quality metrics What is CI in Enter?
  9. squizlabs/php_codesniffer • Packagist • GitHub • Documentation Detects violations of

    a defined set of coding standards. a typical configuration
  10. phpmetrics/phpmetrics • Packagist • GitHub • Homepage Static analyzer tool

    for PHP: Coupling, Cyclomatic complexity, Maintainability Index, Halstead's metrics... and more! a typical configuration
  11. Solutions that I have tried • RSYSLOG, our choice (+

    Fabric with Python scripts as a tool for analysis) • ELK stack Solved problems through logs aggregation • understanding of what is happening in a runtime on a large VPS cluster
  12. Simple script on the basis of decision 1. get the

    base name of fpm log files: ls pool-*.log 2>/dev/null | cat 2. get errors for each of them: cat %s* | grep -Eo "PHP.*[0-9]" | sort | uniq -c 3. send email to the team
  13. • search performance bottlenecks • assessing adequacy of an algorithm

    • reducing algorithmic complexity Solved problems through profiling
  14. • Blackfire, our choice • XHProf with XHGui or XHProf.io

    • Xdebug with KCachegrind/QCachegrind Tools that I have tried
  15. Thank you for your attention! Have questions? Kamil Samigullin a

    some developer [email protected] @ikamilsk github.com/kamilsk linkedin.com/in/kamilsk