java: Add missing stubs to exercises

The problem

Right now for some exercises, a student is required to read the tests to know which functions they should implement. This is annoying, time consuming and might discourage people from doing the exercise entirely. We should provide stubs for all exercises. Stubs should provide the signature of functions and classes, just so the student is immediately ready to start writing the custom logic. This is an example of a stub, from the Raindrops exercise:

class RaindropConverter {

    String convert(int number) {
        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
    }

}

All stubs must follow this format.

Contributing to this issue

This is a big issue that will require changes to a lot of exercises. The good news is that you don’t need to fix this is all exercises to contribute to this issue! PRs fixing this in just one exercise at a time or a couple of exercises at a time are more than welcome.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 34 (27 by maintainers)

Commits related to this issue

Most upvoted comments

I went through the practice exercises and found two more exercises without stubs, opened PRs to add them. Once they are merged I believe this issue can be closed as completed!

The following still lack stubs:

allergies
all-your-base
alphametics
anagram
atbash-cipher
bank-account
beer-song
bob
book-store
bowling
change
circular-buffer
clock
complex-numbers
crypto-square
custom-set
diffie-hellman
dominoes
flatten-array
food-chain
forth
go-counting
grade-school
grep
hangman
house
knapsack
matching-brackets
meetup
minesweeper
nucleotide-count
ocr-numbers
palindrome-products
parallel-letter-frequency
pascals-triangle
phone-number
pig-latin
poker
prime-factors
pythagorean-triplet
queen-attack
rail-fence-cipher
rectangles
rest-api
robot-name
robot-simulator
roman-numerals
run-length-encoding

I grepped for “Since this exercise has a difficulty of”

@PakkuDon I think they are all pretty much open 😃

It seems here in the Java track, all “medium” difficulty exercises or above don’t include stubs, so probably those are a good start, but there might be more. A quick jq query for exercises that are medium difficulty or above gives me this:

jq query
$ jq '.exercises.practice | map(select(.difficulty >= 4)) | map(.slug) | sort' config.json
[
  "affine-cipher",
  "all-your-base",
  "allergies",
  "alphametics",
  "anagram",
  "atbash-cipher",
  "bank-account",
  "beer-song",
  "binary-search",
  "binary-search-tree",
  "bob",
  "book-store",
  "bowling",
  "change",
  "circular-buffer",
  "clock",
  "collatz-conjecture",
  "complex-numbers",
  "connect",
  "crypto-square",
  "custom-set",
  "diamond",
  "diffie-hellman",
  "dominoes",
  "error-handling",
  "etl",
  "flatten-array",
  "food-chain",
  "forth",
  "go-counting",
  "grade-school",
  "grep",
  "hangman",
  "house",
  "isbn-verifier",
  "isogram",
  "kindergarten-garden",
  "knapsack",
  "largest-series-product",
  "linked-list",
  "list-ops",
  "luhn",
  "markdown",
  "matching-brackets",
  "matrix",
  "meetup",
  "minesweeper",
  "nth-prime",
  "nucleotide-count",
  "ocr-numbers",
  "palindrome-products",
  "parallel-letter-frequency",
  "pascals-triangle",
  "phone-number",
  "pig-latin",
  "poker",
  "prime-factors",
  "proverb",
  "pythagorean-triplet",
  "queen-attack",
  "rail-fence-cipher",
  "rational-numbers",
  "rectangles",
  "rest-api",
  "robot-name",
  "robot-simulator",
  "roman-numerals",
  "rotational-cipher",
  "run-length-encoding",
  "saddle-points",
  "satellite",
  "series",
  "sieve",
  "simple-cipher",
  "simple-linked-list",
  "spiral-matrix",
  "sublist",
  "sum-of-multiples",
  "tournament",
  "transpose",
  "tree-building",
  "triangle",
  "twelve-days",
  "two-bucket",
  "variable-length-quantity",
  "word-count",
  "word-search",
  "wordy",
  "yacht",
  "zebra-puzzle",
  "zipper"
]

There might be other exercises marked as easy that might not have stubs, so it might be worth to also double-check those.

About other tracks…I don’t know the state of stubs in other tracks other than the Go track, which has them. Also note the inclusion of stubs is something that each track can decide independently, some tracks might decide to not include them on purpose. If you are thinking on contributing a similar change to other tracks, please confirm the stance of each track on including stubs before proceeding.