Imperative Loop or Functional Stream Pipeline? Beware of the Performance Impact!

I like weird, yet concise language constructs and API usages https://twitter.com/nipafx/status/1055451667079008256 Yes. I am guilty. Evil? Don't know. But guilty. I heavily use and abuse the java.lang.Boolean type to implement three valued logic in Java: Boolean.TRUE means true (duh) Boolean.FALSE means false null can mean anything like "unknown" or "uninitialised", etc. I know - a … Continue reading Imperative Loop or Functional Stream Pipeline? Beware of the Performance Impact!

Don’t Extract Everything Into a Method

Every now and then, I tweet something like this, just to piss off some clean coders: https://twitter.com/lukaseder/status/885498470542577673 Apart from the obvious trolling factor (why can't I ever resist?), I do think there's something thought provoking in such a tweet. First off, given how rare break and continue statements are in Java code, many people probably … Continue reading Don’t Extract Everything Into a Method

SQL, Streams, For Comprehension… It’s All the Same

Recently, at Devoxx, I've seen this beautiful slide in a talk by Kevlin Henney https://twitter.com/lukaseder/status/796704785936293888 In his talk, he was displaying a variety of approaches to solve the FizzBuzz "problem", including a couple of very elegant solutions in completely declarative approaches and languages. In this particular slide, Kevlin used a notation that is derived from … Continue reading SQL, Streams, For Comprehension… It’s All the Same

Comparing Imperative and Functional Algorithms in Java 8

Mario Fusco's popular tweet impressively shows what the main difference between imperative and functional approaches to similar algorithms really is: https://twitter.com/mariofusco/status/571999216039542784 Both algorithms do the same thing, they're probably equally fast and reasonable. Yet, one of the algorithms is much easier to write and read than the other. The difference lies in the fact that … Continue reading Comparing Imperative and Functional Algorithms in Java 8

Rare Uses of a “ControlFlowException”

Control flows are a "relict" from imperative programming, which has leaked into various other programming paradigms, including Java's object oriented paradigm. Apart from the useful and ubiquitous branch and loop structures, there are also primitives (e.g. GOTO) and non-locals (e.g. exceptions). Let's have a closer look at these controversial control flow techniques. GOTO goto is … Continue reading Rare Uses of a “ControlFlowException”