Usability

While maintainability is predominantly about catering to other programmers, usability is about catering to all users, whoever they may be. We can say that there are two broad groups of users that are engaged in our service:

  • People wishing to wield the power of our code via interfaces (GUIs, APIs, and so on)
  • People wishing to make changes to our code to accomplish new tasks or fix bugs

Usability is about making our code, and the functions and interactions it enables, as useful and easy to use as possible for the full gamut of users. All code is written with at least one use case in mind, and so it is fair to judge code based on the extent to which it fulfills that purpose. Usability, however, goes further than this. Usability is not only about fulfillment of user requirements; it's about creating experiences that enable a user to achieve their goals with minimal hassle, time, and cognitive effort.

Usability is vital whether we are creating user interfaces on the web or deeply embedded server infrastructure that'll rarely see the light of day. In both cases, there are users we are providing for, and so we must care about usability.

Have a look at this function's signature and try to discern how you would go about using it:

function checkIsNewYear(
configuration,
filter,
formatter,
MDY,
SMH
) {...}

This function is a real function signature from a code base I once worked on. It had no documentation and the code within it was spaghetti. It was used to calculate whether a given time could be considered a new year and would decide when a Happy New Year message would be shown to a user. It's incredibly unclear how to use it though, or how it works. Some open questions I would have upon discovering this function might be as follows:

  • What is configuration and what is available to configure in such a simple function?
  • Presumably, SMH is seconds, minutes, and hours, but what kind of value is it expected to be? An object?
  • Presumably, MDY is months, days, and years, but what kind of value is it expected to be? An object?
  • What year does the function compare the passed date for when discerning whether it is a new year?
  • Would any date in the ostensible new year work or only, for example, January 1?
  • Why are there filter and formatter arguments and what do they do? Are they optional?
  • What does the function return? A Boolean? The formatter argument would suggest not.
  • Why can't I just pass a date object instead of individual date components?

The function may do as required, but, as you can see, it's not very usable. It takes significant time and cognitive effort to figure out how it works. To figure it out fully, we'd have to study its usages in other parts of the code and try to decipher the spaghetti within. As a user of this function, I would personally find the entire process utterly painful.

Usability is, if anything, about avoiding this pain and burden. As programmers, we engage in the creation of abstractions to simplify complex tasks, but all the preceding code achieves is further complication of a simple problem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.156.93