Posts Tagged: Java

java code

Java … FunctionalInterface … WTF?

Posted by & filed under , .

If you’ve been doing “stuff” with Java 8 for a while I’m sure you’ve stepped into lambdas territory and the joys of succinct code it allows to be written. And if you are like me you probably found yourself using lambda’s everywhere you are confronted with a single-method interface. Which is allowed. In fact it’s […]

Why You Should Use Default Methods in Java 8 Interfaces

Posted by & filed under , .

With Java 8, Oracle introduced the concept of “default methods” in interfaces (and if you really haven’t heard of this — wtf?? — you can read more here about it: https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html). This argue some is a step towards multiple inheritance and as such should be banished from the oh, so pure! Java language. Others point out […]

Java Map and Subtleties of getOrDefault vs computeIfAbsent

Posted by & filed under , .

I wrote recently about the new niceties in the Map interface that Java 8 brought to light where I’m highlighting in particular 2 new methods: getOrDefault and computeIfAbsent (see my previous post here about it). These provide a cleaner (and as it turns out faster too!) way of retrieving values from a Map instance. However, […]

Java 8 — Map and the Unknown “Niceties”

Posted by & filed under , .

Despite Java 9 making its way into the real world nowadays, I see a lot of Java code out there still relying on the old-style Java 6-like syntax. And I’m not talking about the usage of lambda’s, stream’s and the likes, but rather some of the improvements Java 8 brought to existing classes in the […]

Please Stop Using Thread.sleep() in Java!

Posted by & filed under , , .

Ok, I need a good moan about this to the extent that it deserves its own blog post, but I had it with the bloody Thread.sleep() method in Java! I know it was the only way to “sleep” back in the day but seriously, but seriously, we have TimeUnit since JDK 1.5 — and nowadays […]

Issue with Jersey Multipart Libraries: Missing start boundary

Posted by & filed under , .

This one had me pulling my hairs off and going crazy trying to figure it out so I thought it deserves a space on my blog 🙂 While it’s what it looks like a small fix, it turned out to be a b**ch in terms of googling for an answer as whatever combination of search […]

Of Validating Inputs in Java and Designing for Extension

Posted by & filed under , .

I read recently an article on DZone titled “Defensive Programming: Why You Shouldn’t Check Input Parameters for Validity” (by the way, you can find the article here: https://dzone.com/articles/defensive-programming-via-validating-decorators) and it made me think — and write this post 🙂 For those of you who don’t have the patience to read the full article, the author […]

Gradle — Customize Startup Scripts for Java Applications

Posted by & filed under , .

OK, so you use Gradle to build your Java projects. And if you use the application plugin in Gradle then you get also the startup script generation so you can ship that straight into your prod servers. Thing is, the application plugin generates a “standard” script — which does include the classpath and a whole […]

JaCoCo / Gradle — Excluding Source Files and Classes

Posted by & filed under , .

I have switched recently from Cobertura to JaCoCo so I started becoming more familiar with this tool. (And since you asked, one of the main reasons for the switch is that Cobertura is absolutely terrible when it comes to Java lambdas and pollutes the output with a lot of warning and messages about malformed Java […]