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

Loïc Faugeron:
Mars Rover, Landing orientation
Jul 13, 2016 @ 15:40:41

Loïc Faugeron is back again with the next part of his "Mars Rover" series of tutorials. In this new article he refactors the current code even more to make it more flexible in the long run.

In this series we're going to build the software of a Mars Rover, according to the following specifications. It will allow us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) and Test Driven Development (TDD). Previously we've created a navigation package, and in it a LandRover class that validates input parameters for our first use case.

We've also started to refactor it by extracting coordinates in their own class. In this article we're going to further refactor LandRover

He found that the coordinates could become floats (or have additional values) and that the orientation could become an angular degree/be vertical. To help this situation, he pulls this logic out into an Orientation class. True to the TDD methods, he starts with the phpspec test and generates the skeleton class based on them. He makes some simple edits to make the tests pass and updates the main LandRover class to use the new Orientation class for these positions.

tagged: mars rover tutorial series landing orientation phpspec

Link: https://gnugat.github.io/2016/07/13/mars-rover-landing-orientation.html


Trending Topics: