Quantcast
Channel: Scratch Where It's Itching
Browsing all 73 articles
Browse latest View live

Dobutsu on Android

Some time ago, I developped a Dobutsu game in Java. Dobutsu is the initiation game for Shogi, the Japanese chess. It is mainly used for teaching kids some of the basics of the game, although it was...

View Article


Instanceofities

If I am not mistaken, the following three lines of code do the exact same thing:System.out.println( myObj instanceof MyClass); System.out.println( MyClass.class.isInstance(myObj)); System.out.println(...

View Article


Interning String Literals

I found this kind of code in our application: public static final String CONSTANT_STRING = "Some value".intern(); Interning a String means storing it into a common pool of Strings managed by the JVM,...

View Article

Trivial Collection Pattern

We have a framework for handling server notifications, where listeners are responsible for producing one or several Events that will be forwarded to the UI part. Although it happens that one single...

View Article

Empty Integer

I just found this interesting piece of code: Integer oldGroupId = ... Integer groupId = (oldGroupId.toString().trim().equals(GUIConstants.EMPTY_STRING)) ? NumberConstants.ZERO_INTEGER : oldGroupId;At...

View Article


Legends of Code

For those of you who are french, student, and like programming, there will be a coding competition in November: Legends of Code Subscriptions are Open! Not a minute to loose...

View Article

Native Renderer Curiosity

The other day, a colleague showed me a window that was not working well. Scrolling a JTable was throwing lots of Exceptions and breaking the rendering. The strange thing was that this window worked...

View Article

EDT Freeze Detector

It is always the same scenario: the support team contacts us with a problem of a "frozen GUI". They send us the logs so that we can investigate, but of course the logs do not show anything. The user...

View Article


When is a SwingWorker really done?

Imagine you have a SwingWorker running, and you would like to know if it has terminated its job. You notice that it has a isDone() method, and say to yourself: "great! I can use it!". But are you sure...

View Article


ToString Overflow

A colleague of mine showed me this code from one of the libraries we are using:    @Override    public String toString()    {        final boolean reuse = false;        try        {...

View Article

Modal vs Always on Top

Here is an interesting piece of code:      public static void main(String[] args) throws Exception {          JFrame alwaysOnTopFrame = new JFrame(\"Always on top Frame\");...

View Article

InvokeDynamic for all?

I spent Tuesday evening at the Paris JUG listening to Remi Forax about his ideas of a new keyword for Java 9. It was an interesting presentation, followed by an even more interesting Q&A...

View Article

How to Align two Labels

Or rather how not to. This is a code a colleague found on our GUI. The developper probably did not know how to align two components, so he decided to do it his own way. There is no easy way to set the...

View Article


You Said Naming Conventions?

I remained speechless...public final class AbstractButtonList

View Article

Double Timeout

The other day, I needed to check if a configuration parameter giving a timeout in number of seconds was really used by our communication layer. I came to the point in the code where we are sending a...

View Article


Le Meilleur Dev de France

Yesterday I took part in the programming competition called The Best Developer in France. The place was the new hyped school 42, with its so-called “swimming pool”, two big rooms filled with Macs with...

View Article

Closure on "Le meilleur dev de France"

After all was said and done, here are the conclusions about this competition:Entry price: 50 euros. Quite expensive for a coding competition with so many sponsors. Especially since many places were...

View Article


Permutations

A simple piece of code for calculating all permutations of a given word:    public static List permutations(String s) {        List list = new ArrayList<>();        permutations(list, s, "");...

View Article

N Permutations and Combinations

Following my last entry, I would like to add the code for permutations of N elements out of a word, which is a simple modification of the previous program:    public static List permutationsN(String s,...

View Article

Java mini GUI Freezes on Windows 7

When migrating to Windows 7, a colleague of mine experienced small freezes in our application GUI when moving his mouse around. Thanks to the Freeze Detector (TM), we logged the following stack: FREEZE...

View Article
Browsing all 73 articles
Browse latest View live