
Welcome to the Mars Rover series, where we will use the following practices:
- Monolithic Repositories - MonoRepo (Monolithic Repositories)
- Command / Query Responsibility Segregation - CQRS (Segregation of responsibility for reading and writing)
- Event Sourcing - ES (Events as source)
- Test Driven Development - TDD (Development through testing)
In this introductory article, we simply denote the specifications of our rover.
')
Note This example is adapted for the needs of a series of articles version of the exercise presented at the
Dallas Hack Club , which now, unfortunately, is.
But first, let's take a quick look at the terms mentioned above.
Monolithic Repositories - MonoRepo (Monolithic Repositories)
A monolithic repository is a single versioned repository containing many packages connected to each other, having the opportunity to be divided into their own repositories, but for reasons of convenience they are folded in one place.
This approach gives us the following benefits:
- navigation
- dependency management
- convenience settings
- test execution
However, it also brings the following disadvantages:
- no hard separation between packages
- scaling limits (disk size, bandwidth)
- there is no possibility of spot access settings (user gets all or nothing)
It makes sense to make such repositories for projects that will be packaged / released together (although separate repositories do not exclude such a possibility)
Note Here are some links for additional acquaintance with monolithic repositories:
Command / Query Responsibility Segregation - CQRS (Segregation of responsibility for reading and writing)
CQRS is about separating the logic of "writing" and "reading", and it can be applied at many levels, for example:
- read-only microservices and microservices for writing
- end points / tasks are read only or write only
- split your models into two (again, read only and write only)
It is important to note that
CQRS can also be
partially applied in a project: use it only when it really makes sense.
Note Here are some links about
CQRS :
Event Sourcing - ES (Events as source)
With
ES, every meaningful action is recorded as an “event.” Tracking such events provides the following benefits:
- playback of events to recreate the state of the application at a specific moment (rollback, repeat, synchronization)
- analysis of the last incoming state (comparing the two options or searching for who did what and when)
As with
CQRS , it is important to note that
ES can also be applied _particle_ in a project: use it only when necessary.
ES is often associated with
CQRS , but they can be used separately.
Note Here are some links about
ES :
Test Driven Development - TDD (Development through testing)
TDD can be reduced to three steps:
- create test
- write enough code to pass the test (quick and dirty, or just "make it work")
- code refactoring (creating clean, “properly working”)
Writing tests to code makes us think about how future code would be used. It’s like writing specifications, but with three goals at once: design, documentation development and automated regression testing.
This approach easily allows you to have high code coverage (although, strictly speaking, you still need to check all possible code paths, not only successful ones).
Note Here are some links about
TDD :
Specs
The purpose of this series is to create software for the rover, according to the following specifications:
The rover will first have to land in a predetermined position. The position consists of the coordinates (
X
and
Y
, which are integers) and orientation (the string value is
north
,
east
,
west
or
south
).
After all this, he will be able to drive using instructions such as
move_forward
(keeping orientation, but moving along the
x
or
y
axis) or
turn_left
/
turn_right
(keeping the same coordinates but changing orientation).
From time to time, he will report the current location (again,
x
and
y
coordinates and orientation).
For example, a rover may have landed on
23
,
42
,
north
and then get instructions to move forward twice, then to the left, and then forward again. When the coordinates are requested, he will report
22
,
44
,
west
.
Decompose the task
From the above specifications, you can identify at least three options for use:
- Landing rover on mars
- Driving
- Location request
What's next
In the
next article we will create a project and its first package:
navigation
.
Note We will use:
Next part:
Rover, Initialization