#lombok

How (not) to extend standard collection classes

Today in ##java, someone had a problem: They wanted a bounded-size PriorityQueue. One solution offered was extending the PriorityQueue class to add this behavior1. This article will talk about why that is not a good solution. Here is an example implementation of this approach: public class BoundedPriorityQueue<E> extends PriorityQueue<E> { private final int bound; public BoundedPriorityQueue(Comparator<? super E> comparator, int bound) { super(comparator); this.bound = bound...

7 minute(s) read

Immutability in Java

Recently in ##java, we had a discussion on what constitutes “immutability” and how to implement it in java properly. Immutability is a core concept for functional programming, and as mainstream languages and ecosystems “catch up” with the safer, less error-prone ideas from functional programming, immutability is wanted in Java projects as well. What is immutability? Asking programmers for their definition of immutability, you will usually receive an answer such as this: An object is...

9 minute(s) read

Interesting Links – 26 Sep 2016

Oh, shit, git! is a site that shows a number of common things git users say, as well as how to fix the situations that cause them. Note that the title indicates that the readers are expected to be of age. Some examples: Oh shit, I did something terribly wrong, please tell me git has a magic time machine!?! Oh shit, I committed and immediately realized I need to make one small change! Oh shit...

2 minute(s) read