alexpetroaica/robot
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
I used the Command Pattern to implement robot instructions to allow maximum flexibility for adding new instructions in the future. The Factory Pattern was used to generate the right instruction based on its code (F/R/L). I tried to make the code more readable, testable and maintainable by abiding by the SOLID principles; I made objects immutable wherever necessary to ensure their state cannot be altered after they are instantiated. I used TDD everywhere except for the input and output services which are tested by the integration test (I figured it should be enough for the scope of this project). To run the code for any other input, you can update the input strings inside the IntegrationTest class. The integration test has no assertions because it serves as a way of playing with the code with different inputs (in the absence of a GUI or API) Obviously, if this was production code, more rigurous integration tests would be required. The project is using Maven, Java8, tests are running using JUnit 5 and I used the Lombok library to reduce boilerplate code such as constructors, getters and setters. (You might need to install the lombok intellij plugin if you don't have it already) Future improvements: - Add validation to input service to validate the incoming string - Add missing tests to ensure robustness and stability in the future Possible extensions: - Add different implementations of the Input interfaces - Add different implementations of NavigationInstruction - Use Spring framework for dependency injection to avoid instantiating components manually everywhere - this would also clean up the integration test harness