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

Loïc Faugeron:
Mars Rover, Locating handler
Sep 21, 2016 @ 10:39:30

Loïc Faugeron continues his "Mars Rover" series of posts today with the latest in the series covering the "Locating" handler, the functionality responsible for handling requests for the rover's location.

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

He makes use of the command bus pattern to create the handling for the module, doing validation in the Command object and a Bus to handle the command and perform its task. He starts, as usual, with the phpspec tests defining a class that can use a "find latest location" type instance and a "find" method to abstract out the location repsonse.

tagged: mars rover tutorial series location handler phpspec

Link: https://gnugat.github.io/2016/09/21/mars-rover-locating-handler.html

Loïc Faugeron:
Mars Rover, Locating package
Sep 14, 2016 @ 09:51:52

Loïc Faugeron continues his long running series covering the creation of a "Mars Rover" package to help teach programming fundamentals. In this latest tutorial he starts on the last use case in the project: requesting the location of the "rover".

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 going to start developing the last one, requesting its location:

Mars rover will be requested to give their current location (x and y coordinates and the orientation).

In this article we're going to create a new package for the location logic.

He starts by giving a justification as to why a new package is being created just for the location requests (when the navigation package could just be asked for that information). With that explained, he starts in on creating the new package and its tests with phpspec. He then adds this package into the current project's Composer configuration and updates the phpspec configuration to tell it about the newly creates code.

tagged: mars rover tutorial series location package phpspec

Link: https://gnugat.github.io/2016/09/14/mars-rover-locating-package.html

Loïc Faugeron:
Mars Rover, Driving event
Sep 07, 2016 @ 10:34:18

In this latest post in the series Loïc Faugeron continues his "Mars Rover" tutorials, this time with a focus on creating the logic that will "drive" the rover around.

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 we've started the second one about driving it. [...] In this article we're going to create the actual driving logic, using Event Sourcing.

He follows the "Command Bus" design pattern and creates the command structure for the DriveRoverHandler to handle the logic related to the DriveRover instance. He starts with the spec (the test) and updates the generated class with the logic in the handle method to record an event happening on the DriveRover instance. He make a few more changes to the functionality for the spec and class to make the tests go green.

tagged: mars rover tutorial series driving event eventsourcing commandbus phpspec

Link: https://gnugat.github.io/2016/09/07/mars-rover-driving-event.html

Loïc Faugeron:
Mars Rover, Driving instruction
Aug 17, 2016 @ 09:47:01

Loïc Faugeron continues his series of "Mars Rover" posts with this new article focusing on a refactor of the currently defined method of "driving" the rover.

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 we've started the second one about driving it. [...] In this article we're going to refactor DriveRover

He points out the reason for the refactor: there could be a desire to have more that one driving instruction in the list to execute. He starts by using phpspec to define the "Instruction" class and some tests to ensure the different directions are handled. He then moves over to the "Instruction" test and moves the code from the "DriveRover" class into it, including the valid driving directions.

tagged: mars rover tutorial series driving instruction refactor phpspec

Link: https://gnugat.github.io/2016/08/17/mars-rover-driving-instruction.html

Loïc Faugeron:
Mars Rover, Driving
Aug 10, 2016 @ 11:24:36

Loïc Faugeron continues his series of "Mars Rover" tutorial posts with the latest covering the driving of the rover.

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), Test Driven Development (TDD)

We just finished developing the first use case, so we can now get cracking on the second one, driving the rover.

As is tradition in this series, he starts with the phpspec testing, defining the DriverRover spec requiring driving instructions to be provided. He generates the code for it and fills in the brief functional details handling the instruction property. He also adds in some validations as far as what instructions it can be given and re-runs the tests to ensure they all pass.

tagged: mars rover tutorial series driving usecase phpspec

Link: https://gnugat.github.io/2016/08/10/mars-rover-driving.html

Loïc Faugeron:
Mars Rover, Event Sourcing code
Aug 03, 2016 @ 10:39:52

Loïc Faugeron has continued his series developing the code for a "Mars Lander" coding exercise with this latest post sharing the actual code for the event sourcing functionality started in the previous tutorial.

In this series we're building 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). Up until now, we've implemented the first use case, "Landing a rover on Mars".

We've also created an event-sourcing package with the following interfaces: Event, AnEventHappened and EventStore. In this article, we're going to implement them.

He then starts in using phpspec to generate the Event class for him and gives it a basic structure. He fleshes this out with a bit of functionality (to make the tests pass) and moves on to the "AnEventHappened" class. He generates the class in the same way as before and adds a "just now" method to return the event that "just happened". The last class, the "EventStore" could do different things depending on the storage method, so he's delaying that for now and will implement it later.

tagged: mars rover tutorial series event sourcing phpspec

Link: https://gnugat.github.io/2016/08/03/mars-rover-event-sourcing-code.html

Loïc Faugeron:
Mars Rover, Event Sourcing package
Jul 27, 2016 @ 11:51:05

Loïc Faugeron has continued his "Mars Rover" series in his latest post today. This series, based on a set of specifications from a development challenge. In this latest post he continues looking at event sourcing and creates a package to handle the eventing to make it more flexible and robust.

In this series we're building 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) Test Driven Development (TDD).

Up until now, we've implemented the first use case, "Landing a rover on Mars" [and] in the last article, we wrote some Event Sourcing code. [...] In this article, we're going to extract them from the navigation package and put them in their own event-sourcing package.

He starts by creating the package itself as a Composer package including the composer.json configuration and a few other files to have phpspec work correctly. He then adds the event-sourcing package to the main project and starts in on using phpspec to generate its basic files. He then updates the main Lander class to use this new package for events. There's no code in the eventing classes yet, but stay tuned for the next tutorial in the series that will update them and get it all working together.

tagged: mars rover tutorial series landing event sourcing package phpspec

Link: https://gnugat.github.io/2016/07/27/mars-rover-event-sourcing-package.html

Loïc Faugeron:
Mars Rover, Landing event
Jul 20, 2016 @ 09:33:05

Loïc Faugeron has posted the latest tutorial in his series about developing a "Mars Rover" script using various design patterns and principles. In this latest part of the series he looks at handling the "landing event" of the rover.

In this series we're going to build the software of a Mars Rover, according to the following specifications. [...] Previously we've created a navigation package, and in it a LandRover class that validates input parameters for our first use case. [...] We've then refactored it to extract coordinates and orientation in their own classes.

In this article we're going to create the actual landing logic, using Event Sourcing

He then starts in, creating the tests first because of TDD, on the LandRoverHandler to integrate a command architecture (using the Command Bus pattern). He then sets up the structure for the event sourcing and an basic event for the landing of the rover. This includes the handler for the event, the event itself and the storage method for capturing that the event happened. He fills in the generated classes with a bit of logic and a few updates to the test for the new structure.

tagged: mars rover tutorial series landing event sourcing orientation phpspec

Link: https://gnugat.github.io/2016/07/20/mars-rover-landing-event.html

Loïc Faugeron:
Mars Rover, Landing orientation
Jul 13, 2016 @ 10: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

Loïc Faugeron:
Mars Rover, Landing coordinates
Jul 07, 2016 @ 11:47:20

Loïc Faugeron has continued his "Mars Rover" series of posts with this latest tutorial covering the functionality for the landing coordinates.

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. [...] In this article we're going to refactor LandRover.

He starts off with the justification of why the LandRover class needs to change and what kinds of new classes need to be made. He starts with the phpspec tests and builds out the Coordinates and Orientation classes (with some basic functionality) to make the movement and direction of the rover more flexible and the meet the test requirements.

tagged: mars rover tutorial series landing coordinates orientation phpspec

Link: https://gnugat.github.io/2016/07/06/mars-rover-landing-coordinates.html