Book cover copyright Martin Fowler
This chapter explains several methods for refactoring functions and their parameters.
I felt like most of this chapter just clicked with me. I do love the “Remove Flag Argument” refactoring because I worked on a piece of software were it was used all the time and I constantly had to look up what the function was doing.
The other day my supervisor asked me an interesting question. He wanted to know how much time we spent developing a new feature. The feature was massive and we started working on it late last year and is just now about to come out of beta. There were a bunch of issues trying to figure this out: nobody was dedicated full time to it, it’s been worked on in fits and starts during that time, and we don’t currently track our time at this level of detail. It became an interesting thought process.
Read MoreBook cover copyright Martin Fowler
This chapter explains several refactoring methods for simplifying conditional logic.
Another two takeaway chapter:
Book cover copyright Martin Fowler
This chapter explains several refactoring methods for moving code that accesses data around so it’s easier to work with
I’ve become a big fan of “Change Value to Reference” as I’ve worked with more complex integration tests. It’s made testing results a lot easier in some cases and has improved performance in others.
The other day I ran into an interesting problem. In one of our integration tests we did the following:
The assertTrue()
check always failed and everything we did showed that the file existed. In order to get around this we had to use PHP’s clearstatcache()
function before the assertTrue()
call.
The reason for this can be seen in this section from https://www.php.net/manual/en/function.clearstatcache.php
When you use stat(), lstat(), or any of the other functions listed in the affected functions list (below), PHP caches the information those functions return in order to provide faster performance. However, in certain cases, you may want to clear the cached information. For instance, if the same file is being checked multiple times within a single script, and that file is in danger of being removed or changed during that script’s operation, you may elect to clear the status cache. In these cases, you can use the clearstatcache() function to clear the information that PHP caches about a file.
PHP was caching the result of is_file()
and causing the assert to fail. To fix the tests we had to add the following call to clearstatcache()
.
Book cover copyright Martin Fowler
This chapter explains several refactoring methods for moving code around and making it easier to clean them up.
Two this time:
functions.php
that was included in every file and it had an if statement that could never resolve to true. Everyone was afraid of removing it for fear that it would break something. I wasn’t. :-)Book cover copyright Martin Fowler
I fell off of this process really bad due to some family reasons but I’m going to start back on this process.
This chapter explains several refactoring methods that involve moving items into classes, out of classes, and into new classes.
I think these are all valuable refactorings to learn but I’m still not sure on how I’ll know to use them when I’m working. I guess I’ll just need to keep reviewing these. :-)
Git Logo from https://git-scm.com/downloads/logos
The other day at work I realized how many open branches we had in our Git repo that had been merged into the master branch but weren’t deleted from our BitBucket repo. I started looking for ways to quickly cleanup the branches without automating the process so I didn’t accidentally delete something that was still needed.
My initial search found that you can delete a remote branch using the following command:
git push origin --delete name-of-branch
My issue was that I needed to delete hundreds of of branches. Luckily you can specify multiple branches for this command like so:
git push origin --delete name-of-branch1 name-of-branch2 name-of-branch3 name-of-branch4
I was able to use git branch --merged
to get a quick list of all the branches that had been merged into master and then I ran the command above on them once I verified they were all “old”.
subscribe via RSS