Working with categories

Structure

The product categories have a simple breadcrumb structure, which is well illustrated by the categories in the sample data, as shown in the screenshot on the right.

Rules

Categories must obey a few simple rules:

  1. The “>” (greater than) character is used as a separator, so for example Wines is a subcategory of Beverages, and its full name is “Beverages>Wines”.
  2. The full name of a category includes the names of all its parent categories. For instance Bitters is a subcategory of Beers, which in turn is a subcategory of Beverages. Its full name is “Beverages>Beers>Bitters”.
  3. Categories can either contain products or other categories, but not both.
  4. If a category contains other categories, its full name end in a separator, e.g. “Beverages>”.
  5. A product can only belong to one category.

The last three rules are not intuitively obvious. They are included to make things easier, both for the user and the app.

Selection

Because categories can be nested, they are represented as a tree structure. The screenshot on the right shows a category being selected from the sample data. The icon for the Beverages category indicates that it contains other categories, but no products. Tapping this category expands it, as shown below.

Note that the Beverages category has expanded, and its icon has changed. Now tapping on it would cause it to contract again, hiding all its subcategories. Beers is another parent category, which shows that categories can be nested more than one level deep.

Author: Philip Sheard

Philip Sheard has been working in IT for over 40 years, and on this project for the last 20. His current skills include Java, Android, Objective-C, iOS, PHP, MySQL, ASP.Net, SQL Server, HTML, CSS, Apache and WordPress.