Menu Sidebar

How to categorize objects

How do you categorize software errors?

There are several possible axes we might think of:

  • Severity: e.g. notice, warning, error, fatal.
  • Module: what library or group of classes did the error come from?
  • Layer: database, framework, controller, model, view.

In Exceptional Ruby, I suggested a different approach for categorizing errors. Rather than thinking of different taxonomies that errors might fall into, think about how various types of errors are dealt with. For instance:

  • Inform the user that they tried to use the system in a way that is either not supported or not permitted.
  • Note that the system is in a state that was never planned for, inform the user of a fatal error, and log a problem report back to the developer.
  • Detect a predictable outage, and either retry automatically, or ask the user to manually retry later.

Then, once we have an idea of how different types of errors are handled and/or reported, we can work backwards from these distinctions in order to come up with a set of categories. Which we can then encode as base exception classes:

  • UserError
  • LogicError
  • TransientFailure

Consider a different domain: tasks in a TODO list. Again, there are a lot of ways that these could be categorized: by urgency, by sphere (work, family, personal), by importance.

The GTD system takes a novel tack: it says, “what properties are we most likely going to want to filter by?” The answers it comes up with are:

  • What tasks can I do where I am right now? (Office, kitchen, out running errands)
  • What tasks do I have time for right now?

Working backwards from these questions, it arrives at the idea of categorizing tasks by “context” and by time needed.

These two examples suggest a general pragmatic rule for categorizing objects: don’t worry about listing “natural” taxonomies. Instead, consider how you will most likely need to filter or sort the items.

In some cases, we might not yet know how we might want to filter or sort the objects. In that case, the rule suggests that we hold off on categorizing them at all.

Please help me find a web design mentor

My wife Stacey is getting back into web design after a 15-year hiatus, with a goal of having a job in the field a year from now.

She may also be interested in development in the future, but design comes first.

She’s on a timeline, and can’t afford to drown in a sea of resources. Suggestions of sites, online schools, organizations that can help, etc. are all useful, but what she really needs is a mentor. Someone who can point her at what to study next, tell her what’s essential and what’s tangential, and help her when she gets stuck.

If this sounds like you, or you know someone who might be willing, we would both really, really appreciate it.

If you don’t want to comment publically, you can use my contact form to get in touch.

Thank you so much!

Getting started with PHP: Essential dev tools

A complaint that I have with pretty much every programming language manual I’ve ever read, is that they almost never start by telling you how to get the tools you need. Sure, they tell you how to install the basic compiler or interpreter for the language, information you could easily discover by following the first Google result. But they don’t tell you where to find the tools that every experienced user knows about and uses every day, but which don’t come with the standard language distribution.

Read More

Older Posts

Virtuous Code

"The three virtues of a programmer: laziness, impatience, and hubris" — Larry Wall

Books and Screencasts

RubyTapas Screencasts

RubyTapas Screencasts

Small plates of gourmet Ruby code.

Confident Ruby

Confident Ruby cover

32 Patterns for joyful coding.

The Making of

Confident Ruby cover

Watch me build an app in Sinatra and Rails

Objects on Rails

Objects on Rails

A developer notebook on applying classic Object-Oriented principles to Ruby on Rails projects.

Exceptional Ruby

Exceptional Ruby

The definitive guide to exceptions and failure handling in Ruby.