Skip to content
William Fiset edited this page Jun 9, 2019 · 18 revisions

Contributing

This repository is contribution friendly 😃. If you're an algorithms enthusiast and want to add or improve an algorithm your contribution is welcome! Please be sure to include tests 😘

Getting started

This project uses Gradle as a build system (and testing). Make sure you have Java 8+ SDK installed and the gradle command-line tool. Run the build command to make sure you don't get any errors:

Algorithms$ gradle build

Adding a new algorithm

The procedure to add a new algorithm or snippet of code is:

  1. Identify the category folder your algorithm belongs to. For example, a matrix multiplication snippet would belong to the com/williamfiset/algorithms/linearalgebra folder. You may also create a new category folder if appropriate.
  2. Add the algorithm implementation to com/williamfiset/algorithms/category/ as com/williamfiset/algorithms/category/FooAlgorithm.java
  3. Add tests for FooAlgorithm in javatests/com/williamfiset/algorithms/category/FooAlgorithmTest.java
  4. Edit the build.gradle file if you added a new category to the project (unlikely).
  5. Test your algorithm thoroughly (see testing section below)
  6. Run gradle goJF to format all Java code according to Google Style Guide.
  7. Send pull request for review 😮

Testing

This repository places a large emphasis on good testing practice to ensure that published algorithms are bug free and high quality. Testing is done using a combinations of frameworks including: JUnit, Mockito and the Google Truth framework. Currently very few algorithms have tests because they were (informally) tested against problems on Kattis in a competitive programming setting, but we are slowly migrating to formally testing these algorithms for robustness. To run all the tests execute:

Algorithms$ gradle test

However, when developing you likely do not want to run all tests but only a subset of them. For example, if you want to run the FloydWarshallSolverTest.java file under javatests/com/williamfiset/algorithms/graphtheory/FloydWarshallSolverTest.java you can execute:

Algorithms$ gradle test --tests "javatests.com.williamfiset.algorithms.graphtheory.FloydWarshallSolverTest"
Clone this wiki locally