Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Cleaning up Code: Is Refactoring for Aesthetics worth It?
Jul 18, 2016 @ 10:16:17

On the SitePoint PHP blog Tobias Schlitt has an article posted that tries to answer the question "is refactoring for aesthetics worth it" for most development groups out there.

Most development teams want to get their codebase into a better, more maintainable state. But what definition of better should be chosen? In many cases, it is not necessary to dig deep into Domain Driven Design (DDD) to achieve this goal. Sometimes, it's even counter productive. But one of the most basic collections of principles can help each team a lot already: Clean Code.

The Clean Code book by Robert C. Martin summarizes many simple and advanced improvements to get better, understandable, and therefore more maintainable code.

He goes on with a bit of example code, showing a getJobs method that has room for improvement. He makes recommendations on cleanup steps like: renaming variables for clarity and breaking up code more visibly based on functionality. He then talks about the "methodology of refactoring" and how to take "baby steps" in your updates rather than major jumps. He ends by pointing out that refactoring for "beauty" sake isn't a good idea nor is doing it without a sufficient level of automated testing to ensure changes didn't break the application.

tagged: refactoring aesthetics babysteps opinion example naming cleancode

Link: https://www.sitepoint.com/cleaning-up-code-is-refactoring-for-aesthetics-worth-it/

QaFoo Blog:
How to Refactor Without Breaking Things
Jun 09, 2016 @ 20:31:50

On the QaFoo blog there's a new post sharing some helpful hints that you can use to refactor your code without breaking things in a legacy codebase.

Refactoring means to change the structure of your code without changing its behavior. It is an essential part of everyday programming and should become knee-jerk for your whole development team. Refactoring is very helpful to cleanup feature spikes, revise earlier decisions and keep a maintainable codebase in the long run. In a perfect project world - with extensive automated tests of various types - this is just a matter of getting used to. But there are only very few such projects. So getting into proper refactoring is much harder. This article will show you important tips to master this challenge with your team.

They point out two things that can help you ensure you break as little as possible: good tests and "baby steps". They go into a bit more detail on these two sections, mentioning how they help with the refactoring process and techniques to follow in the process.

tagged: refactor break functionality tests babysteps tutorial

Link: https://qafoo.com/blog/085_how_to_refactor_without_breaking.html