java.util.concurrent.CompletableFuture
is a versatile utility in Java (since Java 8). It provides a means of task execution, both synchronous and asynchronous.
A CompletableFuture implements java.util.concurrent.Future
(available since Java 5) and java.util.concurrent.CompletionStage
(available since Java 8) and adds additional methods for operating on tasks.
Some additional documentation about the three in this kata:
A code-kata is a coding exercise that builds muscle memory by a practice of programming to arrive at a known solution.
The essence of the exercise (presentation material and code kata) is to demonstrate the
usage patterns for CompletableFuture
.
This set of code katas rely on fixing broken code. There may be multiple ways to solve the broken code, the intent is to learn and experiment. There is a driving main class and there are recipe parts, which need to be fixed.
The project contains several java classes that fail to cook our recipe. A recipe mindmap to prepare Paneer Tikka Masala is included below.
-
Checkout the code from a terminal/command prompt.
-
Setup the project in your IDE.
-
IntelliJ: Launch your IDE and point to the pom.xml to be opened as a project.
-
Eclipse: Import Existing Maven Projects.
-
Netbeans: Open Project, then run
mvn verify
. -
Any other IDE: Ensure that the
src/main/java
,src/kata/java
andsrc/solution/java
are on the source path.
-
-
Run the main class PaneerTikkaMasala.
-
None of the cooking recipe parts will print out on your console.
-
Fix the broken/empty sections of code using the TODO and HINT comments.
-
Repeat above steps until all recipe parts are printed.
-
Check the solutions to see if there are other ways to solve. (Remember, the solution may be less performant than yours)
-
Rinse and repeat (delete and checkout again, then back to Step 1) to build muscle memory.
Start in the following oder to fix the broken code or add code where empty. Follow the TODOs and HINTs. Your IDE should list out all TODOs.
-
Part1CheckIngredients - Checks for the ingredients for the recipe.
-
Part2aMakePaneerTikka - How to make the Paneer Tikka (cottage cheese roast).
-
Part2bMakeMasala - How to make the Masala (pureed/spiced gravy).
-
Part3Cooking - How to cook the Paneer Tikka and the Masala, then garnish.
-
PaneerTikkaMasala - Plays the role of a chef and orchestrates the entire cooking.
Mission
Your mission, should you choose to accept it, will be to fix the recipe. This message will self-destruct in* NaN minutes
How to prepare for coding along
This kata is developed as a Java maven project. Ensure that you have:
-
Apache Maven 3.6.x or above. Tested with Apache Maven 3.6.3. Link: https://maven.apache.org/download.cgi
-
JDK 11 or above. Tested with OpenJDK 15. Link: http://jdk.java.net/15/
-
Your favorite Java IDE. IntelliJ IDEA Ultimate was used to develop this kata.
|____IDE <----- Contains Run Configurations and Live Templates for IntelliJ |____pom.xml <----- The POM for running maven commands |____README.adoc <----- This file |____assets <----- Images and docs linked above |____src | |____main | | |____resources | | |____java | | | |____none | | | | |____cgutils | | | | | |____recipe | | | | | | |____paneer | | | | | | | |____tikka <----- Common classes shared by Kata and Solution portions | |____kata | | |____java | | | |____none | | | | |____cgutils | | | | | |____recipe | | | | | | |____paneer | | | | | | | |____tikka <----- The broken recipe code, that needs to be fixed | |____solution | | |____java | | | |____none | | | | |____cgutils | | | | | |____recipe | | | | | | |____paneer | | | | | | | |____tikka <----- Solutions | |____test | | |____java | | | |____none | | | | |____cgutils | | | | | |____recipe | | | | | | |____paneer | | | | | | | |____tikka <----- Some tests for utilities used in this project
Kata |
Solution |