Development exercise inspired by https://www.hackerrank.com/challenges/cube-summation using Laravel 5.2
The list of changes between the base Laravel installation and the final product can ve viewed by clicking here
##Usage
This project is currently deployed in a Heroku instance.
To use the text input processing implementation, click here and submit a valid input for the problem described in the Hackerrank challenge. If the input is incorrectly formatted or the instructions are invalid, you'll see an error message.
To use the database implementation, click here. You can use the UI to create a new Matrix, update cell values and query the matrix. Invalid instructions will show an error message.
###Business Logic Layer
####app/Classes/DataMatrix.php
This business logic class handles the creation of a new DataMatrix structure (for the text input processing implementation), along with cell value updates and queries. This structure is used for the regular input processing that can be viewed clicking here
####app/Classes/InstructionHandler.php
This business logic class handles the decoding and processing of the instruction input (for the text input processing implementation), along with cell value updates and queries. This structure is used for the regular input processing that can be viewed clicking here
####app/Exceptions/InstructionParseException.php
This exception is used when the instructions from the text input cannot be parsed correctly.
####app/Exceptions/InvalidInstructionException.php
This exception is used when one of the instructions from the input is parsed correctly, but the instruction intself is invalid (out of range, for example)
This file defines the URL routing and methods for the application.
###Web Layer (Controller in MVC)
####app/Http/Controllers/CubeSummationController.php
This controller handles the display and instruction processing for the text input processing implementation.
####app/Http/Controllers/CubeSummationDBController.php
This controller handles the display and instruction processing for the database implementation. In it's current implementation, only one instance of a matrix can exist (Meaning, each time a new matrix is created, the old one gets deleted). This is in order to overcome a 10k row limit Heroku has for free environments.
###Persistence Layer (Model in MVC)
Model for the 'cells' table (storing position and value of each cell)
Model for the 'matrices' table (storing the size of the matrix). This model is related to the Cell entity via a one-to-many association (meaning each cell belongs to one matrix, and a matrix can have N3 cells)
####app/Persistence/DataMatrixService.php
This class handles the different database persistence operations (delete and create a new matrix, update a cell value and query the matrix).
####database/seeds/DatabaseSeeder.php
Database seeds for the application tables.
####database/migrations/2016_07_06_025353_create_tables.php
Database migration that creates the matrices and cells tables.
###Presentation layer (View in MVC)
####resources/views/layouts/master.blade.php
Main layout template for the application.
####resources/views/cube-summation.blade.php
View template for the text input processing implementation.
####resources/views/cube-summation-db.blade.php
View template for the database implementation.
###Configuration
####app/Providers/AppServiceProvider.php
This class defines the output format for the Blade template engine, allowing the display line breaks as an HTML <br />
.
This class also defines custom validators that are used in the database implementation UI.
####config/app.php
In the app config file, providers and class aliases are defined. The HTML helper and FORM helper were added.
Database configuration. This file was changed in order to deploy the application in Heroku.
###Tests
Test for the Data Matrix business layer class (tests for matrix manipulation in memory and error handling).
####tests/InstructionHandlerTest.php
Test for the Instruction Handler business layer class (tests for instruction parsing and error handling).
Tests for the CubeSummationController.
Tests for the CubeSummationDBController.
###Heroku Related
####Procfile
This file was added in order to enable support for the application using Heroku
###Other
####composer.json and composer.lock
Composer files for dependency management.