Category Archives: Development

Software development topics

Catching Java Assertion Errors

The Java assert statement can be used for conditionally checking program invariants. Assertions are enabled or disabled with the desired level of granularity by Java Virtual Machine flags, as described in the linked guide. So far, so similar to assertion facilities in other languages. However, whereas .NET Debug/Trace.Assert shows and logs a message by default, […]

JavaFX Chart Coloring

Working on a Java(FX) port of my hoplite simulator Myriarch, I ran into an unexpected problem with the history chart. This part of the “Simulation Report” dialog shows how each faction’s unit count changes over the course of the simulation. You can see a screenshot from the current build below. The control is a standard […]

Compiling Java Code

This post is a quick introduction aimed at programmers experienced with C# or other languages who are new to Java. It is intended as a companion piece to my article Java for C# Programmers which focuses on language differences. See the “Further Reading” section at the top of that article for the official Oracle tutorials […]

JavaFX Snapshot Scaling

If you try taking image snapshots of a JavaFX Node on a high-DPI system, you’ll find that the result is strangely blurry. This is an unfortunate side effect of the JavaFX DPI scaling introduced in Java SE 8u60. At resolutions greater than 120 DPI, JavaFX automatically treats all coordinates as abstract “layout pixels” with a […]

Programming Languages in 2016

According to two out of three major language surveys I consulted for 2016, programming is increasingly becoming synonymous with web development in JavaScript. No doubt this reflects, on the developer side, the rapid march towards web services and HTML applications everywhere in computing. Other than JavaScript and HTML itself, though, a stable comprehensive application framework […]

Java StAX Tips

StAX stands for Streaming API for XML APIs, meaning the XML reader and writer that are contained in package javax.xml.stream of the Java standard library. The first tip is to know this API exists and you should use it! The older APIs, Simple API for XML APIs (SAX parser) and Document Object Model APIs (W3C […]

JavaFX Pane Clipping

Most JavaFX layout containers (base class Region) automatically position and size their children, so clipping any child contents that might protrude beyond the container’s layout bounds is never an issue. The big exception is Pane, a direct subclass of Region and the base class for all layout containers with publicly accessible children. Unlike its subclasses […]

JavaFX Spinner for Numbers

The JavaFX version of the popular up-down control is called Spinner. Like its Swing progenitor JSpinner, this control is much more flexible than a typical numerical up-down control. Spinner is designed for arbitrary sequences of objects, with number ranges constituting merely a special case. This has some unfortunate consequences when you do wish to make […]

Java Method Reference Evaluation

Along with lambda expressions, Java SE 8 introduced method references as a shorthand notation. These are mostly used to reference static methods (e.g. Double::toString) or constructors (e.g. String[]::new), and these uses are straightforward. However, method references to instance methods can yield results that differ from lambda expressions in surprising ways. This is because the invocation […]

Algorithms in a Nutshell

Algorithms in a Nutshell — George T. Heineman, Gary Pollice & Stanley Selkow, O’Reilly 2016 (2nd ed.), ISBN 978-1-491-94892-7 This fairly slim book covers the basics of algorithmics and benchmarking, and also provides pseudocode and implementations (in C/C++, Java, and Python) for nearly 40 important algorithms. The major drawback is obvious when you consider that […]