Photo by Nguyen Dang Hoang Nhu on Unsplash

When JUnit runs a group of tests, the tests are usually run in a seemingly random order. If your tests are A, B, C, D and E, they might run in the order C, A, B, E, D, for example.

For the vast majority of projects, that’s just fine. After all, in real life, you can’t always predict what order events will occur in.

But what if you do need to run tests in a specific order? JUnit 5 provides a mechanism for that, as does JUnit 4 (and probably so does JUnit 3). …


Photo by Timothy Eberly on Unsplash

So the other day I pushed some changes to one of my Git repositories and I was asked to enter my username and password, something I hadn’t needed to do in weeks. Then I got an e-mail from GitHub.

Hi @Alonso-del-Arte,

You recently used a password to access the repository at Alonso-del-Arte/chess with git using git/2.26.0.windows.1.

Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.

Thanks,
The GitHub Team

Huh? What? Are you as confused as I am? Are all passwords going to…


As of June 1, 2021, restaurants in Michigan are allowed to ramp up to 50% capacity. They were restricted to 25% capacity because of health department restrictions. If you go eat at a restaurant, tip your waiter well. Photo by Bimo Luki on Unsplash

Single-purpose calculators are frequently used as exercises for Java beginners. The instructor tasks the students with writing a command line program that calculates the area of a room in square feet, or it calculates body mass index (BMI), or it converts an amount of money in one currency to another, etc.

To do the same thing with a graphical user interface (GUI), such as with Java Swing, would be too difficult for a Java beginner, because there is a lot more overhead. Or is it? After all, the three major integrated development environments (IDEs) include GUI form designers.

In this…


Photo by Kajetan Sumila on Unsplash

The concept of object-oriented can feel quite difficult to comprehend, with all its arcane concepts, inscrutable jargon and indecipherable acronyms. It’s actually a very simple concept that anyone can understand, if it’s explained clearly enough.

Though explaining it simply might be difficult. I’m going to try with this article. My goal here isn’t to impress you with my knowledge of object-oriented programming and make you feel like a dummy, there are plenty of other people out there doing that.

I hope that I get comments saying I’ve made the concept sound very clear. You won’t be able to create a…


Photo by Laura Ockel on Unsplash

Don’t Repeat Yourself (DRY) is a principle worth observing, within reason. Java has a reputation for being verbose, and certain kinds of repetition in Java seem unavoidable.

One kind of repetition that sometimes occurs is constructor validation redundancy, in which several constructors in a class check their parameters for the same characteristics.

Such repetition can cause serious problems when it’s necessary to make a change to a class, and the programmers fail to notice that certain lines that were duplicated were not changed together.

Constructor chaining can at least sometimes help you avoid such repetition of constructor parameter validation. That…


Photo by Tim Shepherd on Unsplash

Field hiding in Java is a somewhat confusing feature of the language, or misfeature, depending on your opinion. Consider this toy example:

public abstract class SomeSuperClass {

public final String something = "Just for the sake of example";

public void printSomethingNumberOfTimes(int number) {
if (number > 0) {
for (int i = 0; i < number; i++) {
System.out.println(i + ". " + something);
}
}
}

}

This of course serves no practical purpose other than to help me make my point. Let’s extend that class like this:

public class SomeSubClass extends SomeSuperClass {…


This dramatic arrangement of chess pieces would never occur in an actual chess game. Photo by Felix Mittermeier on Unsplash

If you know abstract classes in Java, and you know a little bit about Scala syntax, you might think you already know how abstract classes work in Scala: pretty much the same as in Java, with a few minor differences.

And you’d be right. Scala abstract classes are a lot like Java abstract classes. The minor differences might trip you up occasionally, though. Or they might be pleasant surprises.

For this article, I’m going to assume that you indeed know about abstract classes in Java, so I won’t rehash the Java syntax, except to compare and contrast to Scala syntax.


Photo by Tim Evans on Unsplash

You can find lots of advice online about several different ways to keep “secrets” like API keys and passwords out of Git repositories, but I haven’t been able to find concrete examples for Java programs. This article will detail those concrete examples.

There are quite a few different ways to keep API keys out of Git repositories, each with its own pros and cons. Some articles explain the pros and cons, but without examples, it’s a little difficult to assess which way is the best way for your particular project.

Hopefully these examples I present here will help you figure…


Photo by Jongsun Lee on Unsplash

The three major integrated development environments (IDEs) all provide neat integration of JUnit, making it very easy to write and run JUnit tests without having to use the command line.

Of course they differ in how they provide that integration. In IntelliJ IDEA, each valid test gets a green play button allowing the test to run by itself, and another green play button to run all the tests in a test class.

There’s no way to run a single test by itself in NetBeans, except of course when a test class contains only a single test. …


CODEX

Schrödinger’s cat is not null. Photo by Myles Yu on Unsplash

Some Java programmers seem to be almost emotionally scarred by null pointer exceptions. It’s no wonder then that null safety is the most advertised Kotlin feature. Turns out that Scala had null safety from the beginning, and it goes a lot deeper than providing an optional or providing nullable types.

The thing is that Scala steers you to be more deliberate in what you declare as a variable and what you declare as a constant. Using IntelliJ to write Scala, you’ve probably seen the warning “var could be a val.”

Null is necessary sometimes. I don’t care about anyone’s regrets…

Alonso Del Arte

is a composer and photographer from Detroit, Michigan. He has been working on a Java program to display certain mathematical diagrams.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store