Take the 2-minute tour ×

When an application presents a user with a list of items, it's pretty common that it permits the user to filter the items. Often a 'filter' feature is implemented as a set of include or exclude rules. For example:

  • include all emails from bob@example.com, and
  • exclude those emails without attachments

I've seen this include/exclude pattern often; for example Maven and Google Analytics filter things this way.

But now that I'm implementing something like this myself, I don't know what to call something that could be either included or excluded. In specific terms:

  1. If I have a database table of filter rules, each of which either includes or excludes matching items, what is an appropriate name of the field that stores include or exclude?
  2. When displaying a list of filters to a user, what is a good way to label the include or exclude value?

(as a bonus, can anyone recommend a good implementation of this kind of filtering for inspiration?)

Edit: My solution

Thanks for your answers. I decided that to use operation to described an include or exclude. So the database fields and program variables are called operation. I like the name because it roughly aligns with the meaning of operation in set theory.

As for how it's displayed to users, I fudged it by never labelling 'include' or 'exclude'. Instead it is always presented as part of a full sentence:


The only label used is 'Restrictions' which I think is more specific than 'Filters'. Our users are ususlly not very technically savvy, so — much as I like the word operation — I decided that displaying a label called 'operation' would be unclear for most of our users. Using full sentences might be a little slower to read, but avoids confusion.

share|improve this question
What's word with the word you already used? "a 'filter' feature is implemented as a set of include or exclude rules". What's wrong with "filter"? –  S.Lott Mar 15 '11 at 10:06
"Removable", "CanRemove" –  umlcat Mar 17 '11 at 21:24
add comment

3 Answers

up vote 1 down vote accepted

If this is something the customer already knows and uses ask them how they would call it. If it is your own pet project name it for your purpose and what comes naturally to you. So looking at your question I would suggest:

  1. ItemIncludeFilter and ItemExcludeFilter
  2. Include Items that: and Exlude Items that: .

The idea behind the labels is that you also give the rules a nice readable to string method so it would read : Include Items that : have name 'aName' and have age > 12

And for an implementation It feels a bit like you need a specification pattern. But it also feels a bit off since you seem to have a very database centric rule set and you already have rules in the DB that probably would need to be translated somehow to a specification. But still you could look at it for inspiration. This is a nice example using EF4 and also looks at performance.

share|improve this answer
I did go with the idea of displaying 'including items that' and 'exclude items that' — though I slightly reworded it. Using sentences to describe things rather than simple labels and values seems to work best here. –  gutch Mar 17 '11 at 23:53
As for the specification pattern, it is an interesting idea but I have not used it in this case. Our code essentially works on a meta-model level rather than on a defined model; the model changes radically for each user and so rules are defined in the database. It probably would be possible to use a specification pattern, but would require good understand of the concept from our users which — with all due respect to them — I think would be too much of a stretch for them. –  gutch Mar 17 '11 at 23:56
Okay, thanks for the feedback and your restrictions labels look great ! The specification pattern was already a bit of a stretch. –  KeesDijk Mar 18 '11 at 7:29
add comment

I usually see the value labeled with a radio button and two options:

  • Only allow condition (whitelist)
  • Allow all except condition (blacklist)

Somewhat this depends on the app though. Whitelists/blacklists on most IP filters or site filters are good examples imho. Go to your browser's exceptions for site security or pop-ups to see one example. Though, filtering searches of data is a bit different, I wouldn't call them whitelist or blacklist.

In the database I would either have the field named "include" and set to either true or false OR I would probably have "mode" equal to either 'include' or 'exclude'. The name doesn't matter too much, there are many that other developers would probably recognize easily seeing your table.

"method", "op", "operation", "filterBy", "invertResults" (bool)
share|improve this answer
+1 for the idea of operation — that's what I decided to go with. It matches up nicely with the meaning of operation in set theory, which is pretty much what filtering is... –  gutch Mar 17 '11 at 23:57
add comment

One of the most robust filtering systems I have seen is the database searching on www.Wowhead.com

They filter on many different fields and have filters based on exclusion, inclusion, >, <, and =. Probably more.

share|improve this answer
The wowhead system is certainly powerful... and it's interesting that rather than have 'include' and 'exclude', it only has 'include' in combination with 'not'. So you can't do "exclude items that bind when equipped", instead you do "include items that do not bind when equipped". In the end I decided that the concepts of 'exclude' is easier to understand than 'include not'. –  gutch Mar 18 '11 at 0:50
add comment

Your Answer


