This application determines movement of particles in a linear field.
Full requirements are described in Animation section of the 'BackendCodeTest' pdf in this directory.
The following software is assumed to be installed and available for the building and running of this application
- Java 8
- Maven, with a junit dependency
Run the maven package or install phase from the root of the application:
> mvn clean package
This will create the following jar file: ./target/animation.jar
Run the included unit tests using the standard maven test phase:
> mvn clean test
To run the application on a single given string, execute the animation jar with two input parameter
> java -jar target/animation.jar {speed-parameter} {initial-chamber-parameter}
For example, to test with a speed of 2 and an initial chamber configuration of ..LRL.. run the application as follows:
> java -jar target/animation.jar 2 ..LRL..
A helper class called ParticleSubmitter (in com.glen.animation.generator) can be used to generate Very Large Chambers for testing. Adjust the values at the start of the main() method to vary the contents, size and quantity of the auto-generated and submitted chambers.
Using this approach on a basic development laptop provided the following preliminary benchmark: a 10,000,000 character chamber with 4,000,000 particles and a speed of 500,000 (1/20 the chamber size) took between 300ms and 1,300ms to process.
- An bad or missing speed (less than or equal to 0) will result in an IllegalArgumentException
- A null input String for chamber configuration will result in an IllegalArgumentException
- The values for left and right particles in the input string are case sensitive.
Depending on the actual usage for this (A one-off script? A production-grade application?), the following improvements might be appropriate:
- Add additional tests
- Use a real logging system (e.g., log4j)