The solutions can typically be found in the solutions folder of the repository, in particular:

The solution will be published after the exercises deadline.

Study the solutions, even if your solution is okay too. Ask (or discuss with a fellow student) if you do not understand the choices made or concepts used. Typically the solutions are quite like performance assessment tasks.

week 01

Kaos at HQ The solution here is to add a test to make sure that pushing multiple elements to the stack returns them in reverse order, because that is what stacks do.
Once you have your tests ready, using it to develop your own stack cannot be that hard.
We have shown it in class (in 9 minutes, test driven!) and there is a youtube film on it with even more explanation.

Fraction exercise. We have two solutions.

  • One developed in class, which is under lessondemos as tddfraction.
    This would the modern variant with two test classes, one using parameterized tests, a JUnit 4 feature described in the test book. Note that this fraction class has less features, but it demonstrates clearly how easy setting up test can be (once you known your tools).

  • The other , the solution of a JAVA1 (yes Java 1) performace assessment some years back, which uses simple asserts (e.g. assertTrue, assertEquals), can be found in the solutions folder as fraction. This fraction is quite complete, feature wise. It has getters for numerator and denominator, more constructors, static factory methods for shorter client code and a more fancy toString()`.

week 02

In the pub exercise

There is a quite elaborate solution by Pia Erbrath in the repository, which can give you some ideas.
Note parts of such solution might reappear in an exam, but we do not expect you come up with all these fancy details in week 2 of this course. But it does provide insight where we are heading, if you follow along. You may also see some concepts of coming weeks used. That is okay and also gives a clue on where we are heading.

Answers to the questions

  • Exceptions 1

e has static type Object and you cannot throw objects (unless you cast them to Throwable, implying that the instance is a Throwable).

  • Exceptions 2

The catch statement misses the Throwable declaration. The compiler complains with error: <identifier> expected although a more appropriate message would have been Type declaration missing. This is a example how compilers work, it assumes that the first token after a parenthesis is the type token and assumes the e fulfils that role.

week 03


Week 3’s olifantys exercise may cause confusion, because there is not one good solution, for the functionality anyway. It is all about getting the relations in the class diagram properly implemented. Functionality you could is throwing a party, inviting teachers and students alike. You could egt inspired by our solution on Olifantys solution in the exercise repository.

The bottom line is: use your fantasy (hint is in the name of the project).

Shape filter

The shape filter exercise is on PECS (Producer Extends, Consumer Super). solution is in the repo under shape filter solution


The exercise is a combination of understanding a class diagram and how to use 'consumers' type safely. Again: PECS. drinkers solution

week 04

Using lambda to implement comparables.

Here you can see that using lambda to implement a comparable is really easy. You will not want it any other way from now on. solution

Two stacks

Using the same test for two implementations is what this exercise is about. You refactor both the tests and the implementation (by extracting the appropriate interface).

Lambda calc.

Combine enum and lambdas. lambda calc solution

week 05

Lambdas and streams.

csv object stream

Best is to start with csvobjectstream, because that can be used in the next project (and might be in the exam). Note how a lambda can be used to express the filter.

Lambda Library

Our solution includes a JavaFX Gui. You may use it as an example for binding.

week 06

Simple Rest Like Protocol

We again use an enum in the implementation, in particular one enum instance for each command type.

week 07

Simple Rest Like Protocol with database

The same as last week, now with a backing database.

Study it to see how we stick to the Do not Repeat Yourselves by avoiding code duplication as much as possible.

week 08

Rest testing workshop

After trying your hand with the wiremock and rest-assured workshop, you should quickly get up and running with this technology, because, when you have it in your fingers, it will help you write rest test very quickly. Concentrate on the rest-assured framework.

Our solution is online .

easy rest crud with postgres tricks.

For the restful president service, stay tuned.