Resurrection In Coding - Part1

Around ten years ago, I tried to become, what was then called, a Sun Certified Java Programmer. I failed miserable, two times in a row. Since then, I've never tried it again - so scared I could fail again. I lost the spark for development and turned my back to it. Since then a lot has happened and changed in my life. I tried out different roles (Test Manager, Exploratory Tester, Scrum Master, Application Manager/PO). I learned a lot from all those challenges, successes and failures. In 2018 a new era began and with it a rebirth of an old passion: my interest in coding. No it's not because I wanted to get more technical as a tester, no. It's me, myself and I who likes to create things. So I came up with my personal #CodingChallenge to #LearnToCode and finally become a OCAJP I in 2019. This is the first blog post of a new series. In here I try to keep track of all the things I collect on my coding journey during the next couple of month. For my personal record, I decided to write it as a diary. Welcome to that journey. Hopefully you'll find some inspirations and ideas for your own adventures here. This journey is not solely on Java, I listed here also other learnings on my way and marked them as General Learning.

June 2018

  • Starting my very first full time assignment as a Java backend Test Automation Engineer.

October 2018

  • Buying the pdf Java for Testers from Alan
  • Buying the book bundle OCA/OCP
  • Getting some practice exams at whizlabs for OCAJP8
  • Start with studying Chapter 1&2 of the OCA Study Guide

April 2019

Monday 22

  • Start with studying Chapter 3 of the OCA Study Guide
    • String is an immutable class. Once a String object is created, it cannot be made larger or smaller, and you cannot change one of the characters inside it.
      • In contrary, the StringBuilder class is mutable.
      • String Builder vs. StringBuffer: At the beginning there was only the StringBuffer class. The StringBuilder class came with Java 5. StringBuffer does the same thing but more slowly because it is thread safe.
      • Never use == to compare String objects! Because you want to have logical equality rather than object equality for String objects.

Tuesday 23

  • String are everywhere in Java and they use up a lot of memory. To solve this issue, Java has a so called string pool (internal pool) that collects all these strings in order to reuse common ones.

Wednesday 24

  • At work and in private I'm using IntelliJ for writing Java code. Today I discovered the Local History feature. Be aware that it doesn't replace proper source control!
  • Understanding Java Arrays: an array is an ordered list. This code
int ids[], types;

creates a variable ids of type int[] and a variable of types of type int. Tricky isn't it? In the real world one shouldn't write such code because it misleads people.

Thursday 25

  • Getting started with JUnit5 Jupiter. Just spotted a nice collection of examples on GitHub which shows how to set it up.
  • What is taking Baby Steps?
  • BabySteps?
  • What is TCR?
    * In September 2018, [Kent Beck]( invented a new [programming workflow called TCR (test && commit || revert)](
    * [Jordi]( implemented the [Mars Rover Kata got implemented through TCR](
    * [TCR, an alternative to TDD?](
    * [Llewellyn Falco]( posted the following tweet:

Friday 26

  • In order to practice and play around a bit, I created this project on GitHub:
* `git commit -m"Setup the initial project setup"`

Saturday 27

  • Studied the rules of the bowling game kata. It took me quite a while till I understood how the scoring model according to Uncle Bobs description works. Here my slightly adapted version:

    The game consists of 10 frames (I call them rounds). In each round a player has two rolls with a ball to knock down a maximum of 10 pins. The score per round is the total number of knocked down pins plus bonuses if the player does a spare or a strike.
    A spare is when the player knocks down all 10 pins with two rolls in a round. The bonus for that round is the score of the next first roll.
    A strike is when the player knocks down all 10 pins with the first roll in a round. The bonus for that round is the score of the next two rolls.
    In the 10th round, a player who rolls a spare or a strike has a third extra roll to finish the round. (fyi: No more than three rolls are allowed in the 10th round).

  • Added a first failing test to the practice project.
  • git commit -m"Add first failing test"

Sunday 28

  • Bowling Game Kata:
    • Second commit "Add first successful test"
  • Guess what the following code snippet will print
int[] numbers = new int[] {3,2,1};
System.out.prinln(Arrays.binarySearch(numbers, 2));

I'll give you the freedom to think a bit and will reveal the solution another day.

Monday 29

  • Looking for an answer to the question: What is reflection in Java?
    • Reflection in Java
      • What is reflection and why is it useful?
      • Roundup: Reflection is a language's ability to inspect and dynamically call classes, methods, attributes, etc. at runtime. For example: all objects in Java have the method getClass() which lets you determine the object's class even if you don't know it at compile time (e.g. if you declared it initially as an Object and later on in your code you want to determine it's exact type).
  • Bowling Game Kata:
    • git commit -m"Add a second successful test" (didn't implement anything additional to make it succeed on the first run)    * git commit -m"Add a third failing test"

Tuesday 30

  • Bowling Game Kata:
    • git commit -m"Set DisplayName on the tests" (doc see JUnit5 assertions)
      • Class BowlingGame: add a global roll array of length 21 (which means 21 rolls max) to count the number of rolls during a game.

May 2019

Wednesday 1

  • Short assertion excursion:
    • Today I was searching for what is called soft assertions in JUnit5. For that purpose there exists the method assertAll(). It does not fail the test at the first failed assertion, but completes the test and reports all failed assertions. This post explains it in more detail.

Thursday 2

  • General Learning:
  • Today I had some funny while searching for some nifty IntelliJ plugins. Here some of the top must have plugins:
  • Java learning:
    • A Java Array is a dynamically created object. It servers as a container that can hold a constant number of values of the same type.
      • A Java ArrayList one of the most used data structure implementation classes in Java. It is a generic re-sizeable collection implementation of the List interface. It is especially used for handling a large number of objects. See the Java API doc for it here (JDK 8).

Monday 6

  • Java learning:
  • Bowling Game Kata:
    • Try to implement business logic to make third test green. But instead the second test fails now. What did I break?

Tuesday 7

  • Java Learning:
    • There is a new logging kid in the town. Meet flogger!
      • Today I learned, that you can get an Method [] of all the methods of a class using reflections. Did some strong style pair programming today, where we had to invoke all method of a class in an external lib. The method invoke(obj, args) from the class java.lang.reflect.Method, returns the result of the invoked method.
  • General Learning:
    • For Windows7&10 user: If you want to use a nice and shiny terminal in IntelliJ, follow these instructions.
  • Bowling Game Kata:
    • Fix business logic to make third test successful.

Wednesday 8

  • Java Learning:
  • Bowling Game Kata:
    • git commit -m"Add a third successful test"     git push     Creating a 4th test for testing the perfect game (a game which is made up just by strikes).

Thursday 9

  • Bowling Game Kata:
    • What is the total score of a perfect game?
      * 270?
      * I guess I have to adapt the last sentence of the  game description to: _In the 10th frame, a player who rolls a spare or a strike has a **second** (for strike) or **third** (for spare) extra roll to finish the frame. (No more than three rolls are allowed in the 10th frame)._

Friday 10

  • Bowling Game Kata:
    • Well well, I guess I have to adapt the description of the Bowling game once more. Doesn't that ring a bell? Ambiguous requirements, specification? Funny isn't it!

Saturday 11

  • Bowling Game Kata:
    • A few calculations later... the maximum score one can get from a perfect game is 290 and not 270.     When I run the fourth test now, I get now expected: <270> but was: <30> hmmm... wth is wrong here?     git commit -am"Add a fourth failing test and update the game description"     Oh I found the bug! I used the break keyword instead of continue in the for loop I wrote, shame on me. And see the test is green now!     Oh I found the bug! I used the break keyword instead of continue in the for loop I wrote, shame on me. And see the test is green now!     git commit -am"Fix for loop bug"     Oh I found the bug! I used the break keyword instead of continue in the for loop I wrote, shame on me. And see the test is green now!

Sunday 12

  • Bowling Game Kata:
    • Adding a fifth test to check if a perfect spare game is possible. But what is a perfect spare game? My definition: In a perfect spare game, the first roll of every frame knocks down 9 pins and the extra roll in the 10th frame is a strike.

Monday 13

  • Bowling Game Kata:
    • Finishing the implementation of the fifth test to check a perfect spare game.
      • git commit -m"Add a fifth test to check a perfect spare game"
      • Oh wait, I forgot a small correction in the Let's do a quick: git add . && git commit --amend
      • Oh dear, a bug made it into my test code. testSimpleRolls: I put the assertion inside the for loop to calculate the final score, which is obviously not a good move.
      • git commit -am"Fix a bug in the test code"

Wednesday 15

  • Java learning:
    • Great advice from Alan: When I code - the main method is one of the last things I write. I very often create tools with no main method until I need to package it for someone else to use. And the main method tends to call a single entry point class which I will have previously have wrapped with an @Test method for my prototyping. (source)
      • Today I was a little bit digging into EnumSet. Examples can be found here.

Thursday 16

  • Bowling Game Kata:
    • Remove continue statements as they are really unnecessary here.
      • Exchange the for loop to a while loop as it simply looks nicer in my opinion.
      • After fixing the assertions of the testASpare() and the testAStrike() methods, all five tests are now passing. Strike!     git commit -am"Remove continue statements and fix test assertions"     Oh, and of course the needs some finishing touches.    * git commit -am"Update README"

Friday 17

Sunday 19

  • Java Learning:
    • For working with dates and time in Java, there does exists the LocalDate, LocalTime and LocalDateTime classes. All these classes are static, which means something like this:
LocalDate date = new LocalDate(); // DOES NOT COMPILE!

So we have to use the static methods e.g:

LocalDate date =;

  * VarArgs lets you do some cool things. Say we want to create an ArrayList in a cool way and populate a List on one line:

List<String> list = Array.asList("Fly", "Mammoth");

Tuesday 21

  • Java Learning:
    • Today my pair programming partner and I, had to retrieve the Java currency object base on it’s numeric code. Funnily enough the java.util.Currency class does not provide such a method out of the box. So we created a lookup map by ourselves:
 for(Currency currency : Currency.getAvailableCurrencies()) {
    if (currency.getNumericCode() == Integer.valueOf(numericCurrencyCode)) {
        dccCardCurrency = currency;

Wednesday 22

  • Java Learning:
    • Today our pair programming goal was to improve the way we do logging in our automation framework. As we all know log-digging is essential for spotting anomalies. In Java there exists a pretty cool logging framework. It is called logback. Our logback.xml looks like this now:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration debug="true" scan="true" scanPeriod="30 seconds" packagingData="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
   <pattern>%boldGreen(%d{HH:mm:ss.SSS}) %highlight([%-5p|) %boldCyan(%60C{60}|%4L]): %boldWhite(%m%n)</pattern>

<logger name="<path> " level="INFO" additivity="false">
 <appender-ref ref="STDOUT"/>
<logger name="path" level="INFO" additivity="false">
 <appender-ref ref="STDOUT"/>
<logger name="path" level="INFO" additivity="false">
 <appender-ref ref="STDOUT"/>
<logger name="path" level="ALL" additivity="false">
 <appender-ref ref="STDOUT"/>
<root level="WARN">
 <appender-ref ref="STDOUT"/>

Thursday 23

  • Java Learning:
    • Optionals is a topic which is hard to digest for me at the moment. I can't really related to it as I've never used them anywhere in my code so far. Maybe I should? Nevertheless, I'm of course interested to learn more about it.
      * [What is it?](
      * [How do I use Optional correctly?](
      * [Should Optional be used as method parameters?](
      * Before there was the class Optional, we had to do something like this:
if(name != null) {

When a program fails because of a NullPointerException, it’s often a result of poor programming practices. This code checks if the name variable is null or not before going ahead to execute some code on it. This approach is lengthy and that’s not the only problem, it’s also prone to error. Indeed, what guaranty us that, after printing that variable, we won’t use it again and then forget to perform the null check. Optional makes us deal with nullable values explicitly as a way of enforcing good programming practice.

  • TODO:
    • Maybe I should release this blog post soon, as I think it's pretty long already ;)

Friday 24

  • Java Learning:
    • Today I spotted Testcontainers! A Java library which makes it apparently very easy to use docker containers for testing. I definitely have to try that out!

Sunday 26

Monday 27

  • General Learning:
    • Visual Code has become a very popular IDE over the last few month. As I’m a Git fanboy, I was of course immediately searching the web if Git is already supported out of the box by code or not. Happily I found this.
      • Postman: For quite a while I was wondering how is it possible in Postman to retrieve an authorisation token, create a global var from the response and then use this var in a PUT request. Finally I found the answer to that. And of course more on that topic.
  • Java Learning:
    • Today I got notified by the static code analysis tool which I’m using in my IDE about the following: A boxed primitive is created from a String, just to extract the unboxed primitive value. It is more efficient to just call the static parseXXX method. That because I was converting a String using valueOf() to an Integer object, which then unboxes it to a primitive int. What I didn’t know so far is, that valueOf() is internally using parseInt() and of top of that providing caching of frequently used Integer objects. So in my case I can go straight ahead and use parseInt() since I just need a primitive int and not an unboxed Integer object ;)

Tuesday 28

  • Java Learning:
    • A working college recommended me this java course on udemy. Looks like a bargain to me, so why not buying it for $12? Let’s grab it! I know that Angie Jones will release her free Java course this Friday and I’m absolutely excited about it! But having two course don’t hurt.    * Binary Search: Here the solution for the little Java riddle from the 28th of April. Remember? What is the output of the following code snippet?
int[] numbers = new int[] {3,2,1};
System.out.prinln(Arrays.binarySearch(numbers, 2));
The output is not predictable because the int array isn't sorted! If the array would be sorted {1,2,3}, the output would be 1 (that's the index position of the primitive int 2 which the binarySearch() returns). 

Wednesday 29

  • Jave Learning:
    • What is inheritance and composition anyway? TL;DR? Here the very short version:
      * Inheritance allows us to model objects that are made up by **inheriting characteristics** of its super types by defining a _is-a_ relationship between them.
      * Composition allows us to model objects that are **made up of/containing** other objects by defining a _has-a_ relationship between them.

Thursday 30

  • Java Learning:
    • Wait a second, what are the core concepts of OOP again? TL;DR?
      * **Encapsulation** is when an objects controls its own state (private member variables). Other objects can only communicate with that object via public methods of that class.
      * **Abstraction** is the logical conclusion to encapsulation. Applying abstraction means that your encapsulated class should only expose high-level methods for using it. All other internal implementation should be set private.
      * **Inheritance** is a way of reusing common logic by implementing a common class. We form a class hierarchy by creating child classes from a common class.
      * **Polymorphism** is when an object can take on _many forms_. Simply put, polymorphism gives us a way to use a class exactly like its parent so there’s no confusion with mixing types. By defining an _interface_ with some common method definitions, each child class can implements its own version of those methods. (for w3schools check [here](

Friday 31

Today Angie Jones released her Java Programming course on TAU! How awesome is that! In the second part of this blog post series, I'm going to compare this course with the one I recently bought from Udemy. I'm going to challenge them! Which one is more in-depth? Which one hast the better practical examples? So watch out and stay tuned!

That's it for this first part of my #LearnToCode #CodingChallenge journey. I hope you can take something for yourself away from it. Maybe you've asked yourself already right at the beginning the question: why in heavens name is he learning Java and not something more freaky like Go, JavaScript, Phyton or even Rust? My answer to that: "Well, Java has followed me ever since. I like the language and want to learn it. Of course I'm interested in learning other languages too, but a bit later." ;)

Life, Laugh and Learn

© 2022 Simon Berner • Crafted with ❤️