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

Mattias Noback:
Refactoring the Cat API client (3 Part Series)
Jul 16, 2015 @ 16:25:54

Mattias Noback has posted a three part series of tutorial articles around the refactoring of a "CatApi" class. These articles take the class from a jumbled mess of functionality with both direct file access and remote requests mixed in into something much more maintainable and flexible.

t turned out, creating a video tutorial isn't working well for me. I really like writing, and speaking in public, but I'm not very happy about recording videos. I almost never watch videos myself as well, so... the video tutorial I was talking about won't be there. Sorry! To make it up with you, what follows is a series of blog posts, covering the same material as I intended to cover in the first episodes of the tutorial.

In part one he introduces the current state of the "CapApi" class and some of the problems with it, both in testing and in structure. He does some basic refactoring to split out some of the logic here and moves on to part two. In the second part of the series he focuses on refactoring the HTTP request and the local file system functionality into abstract, injectable objects. Finally in part three he adds in some verification around the data being passed back and forth between objects including both simple checking and the use of value objects.

tagged: refactor api class series part1 part2 part3 filesystem http request xml validation

Link: http://php-and-symfony.matthiasnoback.nl/2015/07/refactoring-the-cat-api-client-part-1/


Trending Topics: