-
Where Did the Code Go? Interfaces in Java
If we correctly utilize Java interfaces, it can help our code achieve a plugin-style design, where we can swap one implementation for another with very minimal changes. Let’s add a couple of interfaces to our code, with a skeleton class that they reference. Read more…
-
Boil Away The Boilerplate! Adding Lombok Code Generation
Code generation tools, such as Lombok can be a huge benefit, but the generated code is still ours to test. Also, they can increase the learning curve for new developers or make the code more difficult to understand if not used carefully. For this post, let’s add Lombok to our build and replace our simple… Read more…
-
Hands Off My Property! Getters and Setters
Getters and Setters are simple methods, but having them can protect your code in case you need to add validations or additional updates in the future. Using a common naming convention helps others find the getters and setters quickly. Read more…
-
Build It! A Simple Maven Build on GitHub
Having a build executed and results logged to the commit in the repo can be incredibly helpful when troubleshooting. Let’s look at how to add an automated Maven build as a GitHub action for our Java101 repo. Read more…
-
Configuration – YAML Style!
Whether configuring Dropwizard, Spring Boot, GitHub actions, Ansible playbooks, or other applications that consume YAML file data, knowing how to read and construct these files may be important. Read more…
-
Once or More! Java’s Do Statement
If you need to execute command(s) at least once, but possibly multiple times, Java’s do statement may help. Read more…
-
Many Times or Not at All! Java’s While Statement
Another option for looping in Java is the while statement. The while loop’s commands will be executed zero or more times, since the expression is evaluated before each loop, even the first. Read more…
-
And Again! For Loops in Java
We may not always know how many elements we might encounter in an array / collection. Even if the count is known, repeating the same commands in the code for all of those elements is not desirable. Read more…
-
Elemental! Arrays in Java
When there is a specific number of items that are related, Java will let us store them together into an array. Read more…
-
Other Java Math / Logic Operators
Let’s review the basic math and logic operators that Java provides, as well as how to find more complex options. Read more…
-
Switcharoo! The Java Switch Statement
In Java, a switch statement can examine possible values for a single variable and either make assignments or perform actions based upon that variable’s value. Read more…
-
Condition and Assignment All In One Statement – The Ternary Operator
A quick discussion about the ternary operator (both condition and assignment in one command) in Java. Read more…
-
Javadoc Comments – Moving the Documentation in with the Code
Javadoc comments can grow and change with the code…and be used to generate automated documentation for the API(s) calling code will use to invoke your code. Read more…
-
Javadoc – Generating Automated documentation
Imagine having documentation generated for you as you do each build. You can use it locally or share it with any other developers using your project as a dependency. Read more…
-
Style Matters! Adding a Checkstyle Build Breaker (Quality Gate)
Style may not matter to the Java compiler, but it does matter to future you and the other developers on your team. By establishing a consistent set of expectations that are enforced in the build, we can save time during peer reviews and future troubleshooting sessions. Read more…
-
Unit Testing, But Faster! Making Unit Tests Run in Parallel
We can speed up the build by making unit tests run in parallel. Even in a small project, this is worth doing. Not only does it speed up the build, but it will also help us find issues like race conditions in our unit tests earlier, before the build grows large enough to negatively impact… Read more…
-
Adding ints! This Time With Exceptions!
Let’s overload our add method again for the int data type. However, this time, when Java does the addition, it’s still going to return an int. Therefore, we’re going to have to do some error checking (AKA throwing exceptions) to make sure that any happy path response is accurate and valid…AKA we don’t go beyond… Read more…
-
First Things First – Getting Started
Need help figuring out where to start? Check out the getting started page. 💚 Read more…
-
You are Exceptional! Error handling in Java
In Java, when the application runs into a situation that it cannot handle, it stops processing that request and instead throws an object that indicates something went wrong, called an Exception. Read more…
-
If only! Let’s Talk Conditions
In Java, we can use statements like the following to control what portions of the code are executed: – if-then – if-then-else Our conditions can be simple tests or they can be chains of tests strung together to make one overall result. Read more…