Guru: Make It Easy On Someone Else
August 20, 2018 Ted Holt
“Make it easy on yourself,” warbled Dionne Warwick when I was just a pup. That may be good advice when severing a romantic relationship, but not when programming computers. Instead of making it easy on ourselves, we who develop and support applications need to make it easy on the people we serve.
Recently I worked on a project in which users had to enter time values into various Web pages. The original specifications stated that users would enter time values in a format we commonly use in the United States: two-digit hour, a colon, two-digit minute, a space, and either AM or PM. For example:
Something seemed wrong about this idea. It would be difficult for me to think of a more unwieldy data-entry format. There are too many opportunities for the user to key the value improperly. What if the user only keys one digit for the hour? What if the user omits the space after the minute?
This story contains code, which you can download here.
HTML supports a type=”time” attribute for the <input> tag, but it was not an option, I assume due to how that attribute behaves in certain browsers. Given the constraints, how could I make time entry as easy as possible for the people who would be using those Web pages?
I decided to write a routine that would allow the user:
- to key time in either 12-hour or 24-hour format
- to key hours and minutes only, or to key hours, minutes, and seconds
- to key a separator character or not
- to use a colon or period as the separator character
- to key a leading zero for one-digit hours or not
- to leave spaces or not
- to key AM or PM, or even more simply, A or P, in either upper- or lowercase
The user could key 8:30 AM and 2:30 PM in any of the following formats and more:
|8:30 A||2:30 P|
|8.30 AM||2.30 PM|
Did it work? You’d better believe it! They liked it so much they changed the Web pages that they had already built to call the new routine.
I put the RPG source code into a single member, which you can compile as a program or module. If you compile it as a program, it will produce a report that shows each step it takes to interpret a time value. This is how I developed the routine. If you compile it into a module, you can create a service program to which other applications can bind. For completeness, I also added a subprocedure that you can call through an SQL interface.
By the way, some years ago, IT Jungle published a routine for entering date values in various formats. That article seems to have become a casualty of our move to WordPress. I will try to put my hands on it and republish it. After all, I may need that routine myself someday.
Think of your own shop. Whether you’re delivering modern browser-based applications or still using green screens, what’s causing the users consternation? What’s eating up their time? What can you do to make it easy for someone else?