Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Monday, January 16, 2017

C# WebClient Parsing JSON Array

This is a snippet of code that calls a RESTful web service and parses the JSON result.  The JSON payload is a list of objects.  The solution uses the .NET class DataContractJsonSerializer and an annotated DataContract.

Saturday, December 3, 2016

Kotlin Callable Reference Notes

Method references were added to Java 8 and you may already be using the double-colon (::) syntax to use a method reference as a parameter.  The semantics in Kotlin are different although a change in 1.1 will address these differences.

This article presents a few examples of passing function references in Kotlin 1.0.

Sunday, November 6, 2016

Securing JavaFX Content Based on Role

This is an example where a MainView contains two child views, AllAccessView and AdminOnlyView.  All of the views are in .fxml and AllAccessView and AdminOnlyView are fx:included in MainView.

A setRole() method is provided by MainViewController.  This method sets an internal field which is tied to a ChangeListener.  The ChangeListener will decide, based on role, whether or not to show both views (for Admin) or just one (for User).

The fx:include code is wrapped up in Boxes to make the adding and removing easier.

I'll expand upon this later.

The code will explain things better.

SecuredApp Source

Monday, October 24, 2016

Disambiguiating Nil Arguments in Swift

Overloading functions in Swift enables you to use the same function name with arguments of different types.  This can lead to an easier-to-use API, especially with code completion.  Instead of having a complement of functions like

  saveAnotherClass(anotherclass), and

you'd just use a single save() function that would accept the three different types.  The previous example becomes

  save(anotherclass), and

Disambiguating Null Arguments in Kotlin

To define a function argument that can accept a null value in Kotlin, you use the question mark (?) operator.  For example,

fun bar(name : String?) { // ... do something

Can accept both a String argument like "Hello, World!" and a null.  If you have another version of bar() that accepts a nullable argument, say

fun bar(name : Int?) { // ... do something w. an Int

You'll run into a problem if you call


To disambiguate this, you need to provide type into to Kotlin. That type info should be a nullable type. In the following code, a method "foo" is updated with a newer version. Both functions can coexist when non-null arguments are passed. The Kotlin as keyword is used to specify exactly which function is to be used for the null value (and the code compiled).