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

Loïc Faugeron:
Mars Rover, Locating refactoring
Sep 28, 2016 @ 15:57:31

Loïc Faugeron has continued his "Mars Rover" series with this latest article posted to his site. In this most recent tutorial he takes some time to refactor some of the current "locating" code and make it fully functional.

In this series we're building the software of a Mars Rover, according to the following specifications. It allows us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) and Test Driven Development (TDD).

We've already developed the first use case about landing the rover on mars, and the second one about driving it. We're now developing the last one, requesting its location: Mars rover will be requested to give its current location (x and y coordinates and the orientation). In this article we're going to create the locating logic.

He starts with the phpspec tests for the Location handling and edits the generated test to integrate the "coordinates" and "orientation" checks. When this test runs phpspec generates the "Location" class with basic logic. This is updated as well with real functionality and the "LandRover" class is then refactored to make use of all of this new functionality. The final code for the "LandRover" class is also included for reference, post-refactor.

tagged: mars rover tutorial series locating coordinates orientation phpspec

Link: https://gnugat.github.io/2016/09/28/mars-rover-locating-refactoring.html


Trending Topics: