My thoughts as an enterprise Java developer.

Wednesday, August 10, 2016

Tight scoping of constants

How do you declare constants that are only needed in a small scope (function or smaller)? I declare them in the tightest scope as final with an all-caps name. I.e.:

final int THRESHOLD = 1000;

That coveys the intent that it is a constant but minimizes scope.

Disable new UI components until the user has had time to react to them

How often do you use a program, decide to take an action (I.e. Press Return), and then have something popup and use your action before you even have a chance to read the popup? I hate when that happens because I don’t even know what I told the computer to do.

Input on a new UI element should be disabled for a short time to ensure that the user actually wants to take action on the new UI element. The delay has to be just long enough for the user to realize that the action may do something differently and not too long to slow down users who know that the popup is coming. So the delay should probably be a few hundred milliseconds.