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

Climbing out of the legacy quicksand

Climbing out of the legacy quicksand

Are you working with a legacy application? Whether you inherited it or if the project just grew out of proportion over the years it can be daunting. The thought of making changes or bug fixing can be enough to give you nightmares. No fear you can take a sigh of relief. All is not lost.

A few years ago I found myself working on a legacy project. It wasn't pretty. It was very challenging but I made it through.

And when the next project and the next one and the next and the one after that were also legacy systems, I soon found it much easier to work on them by being more methodical.

Antonis Pavlakis

December 02, 2016
Tweet

More Decks by Antonis Pavlakis

Other Decks in Programming

Transcript

  1. Climbing out of the legacy quicksand Antonis Pavlakis @pavlakis |

    pavlakis.uk PHP East Midlands December 2016 @PHPem
  2. “Legacy code is source code that relates to a no-longer

    supported or manufactured operating system or other computer technology. ” –Wikipedia (1/3) https://en.wikipedia.org/wiki/Legacy_code
  3. “… source code inherited from an older version of the

    software.…” –Wikipedia (3/3) https://en.wikipedia.org/wiki/Legacy_code
  4. And can also be… * Insecure, * difficult to read,

    * difficult to test, * hard to maintain, * spaghetti code, * etc…
  5. Some positives… It’s been tried and tested Users know how

    it works Users are aware of the quirks and workarounds
  6. Development Environment If using Vagrant Have a custom box Use

    provisioning just for the application Expose Database port Enable MySQL logging
  7. Expose DB port Edit /etc/my.cnf in the VM and within

    the [mysqld] section, add: bind-address = 0.0.0.0
  8. Expose DB port Give DB user privileges to access DB

    from anywhere: use mysql; update user set host='%' where user=‘app_user' and host='127.0.0.1'; flush privileges;
  9. Enable MySQL logging general_log = 1 general_log_file = /vagrant/mysql.log Edit

    /etc/my.cnf in the VM and within the [mysqld] section, add:
  10. T esting environment A lightweight environment (Vagrant, Docker, OS native)

    Initially we just need PHP (so can use latest version)
  11. DIC $di = new My_App_DiContainer(); $auth = $di->get(‘customer.auth’); $auth =

    (new \My\App\DiContainer)->get(‘customer.auth’);
  12. Git

  13. What do we need to know? Do users have different

    roles? What happens if … Login fails User forgets their password …
  14. What do we need to know? Do users have different

    roles? We have two types of users. Customers and Staff members What happens if … Login fails A Customer’s account will lock for 5 minutes if they enter a wrong password more than 3 times. User forgets their password - A Customer can reset their password
  15. Ubiquitous language Identify the terminology the Users use Use the

    same language/terminology the user (or client) uses to describe the system
  16. Domain Knowledge Understand what the feature was designed to do

    How it is supposed to work How it actually works Any special quirks or edge cases
  17. Resources Modernizing Legacy Applications in PHP - https:// leanpub.com/mlaphp T

    est Legacy apps with Behat - https:// speakerdeck.com/agpavlakis/test-legacy-apps- with-behat DB Shell Script - https://github.com/pavlakis/ phpnw15-behat-tutorial/blob/scripts/scripts/db.sh