Browse Prior Art Database

Using Bit Flags to Regulate Code Availability

IP.com Disclosure Number: IPCOM000031531D
Original Publication Date: 2004-Sep-28
Included in the Prior Art Database: 2004-Sep-28
Document File: 3 page(s) / 29K

Publishing Venue

IBM

Abstract

A programming technique to enable or disable specific features in a product.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 45% of the total text.

Page 1 of 3

THIS COPY WAS MADE FROM AN INTERNAL IBM DOCUMENT AND NOT FROM THE PUBLISHED BOOK

TUC820020027 Dale Crockatt Dale H Anderson, Linda Benhase

Using Bit Flags to Regulate Code Availability

Disclosed is a programming technique to enable or disable specific features in a product. As each new feature is added to, or initially designed into, a product, a 'feature' bit is associated with the code used to implement the feature, and it is used to control whether or not that feature is available to the program. While feature bits are not new, they are typically set at compile time, or stored as persistent data in a file or database. The technique described here allows the user to set the feature bits at runtime and offers a more refined control over their modification.

Feature bits are stored in a private variable of a version object as an arbitrary precision integer. Associated with each feature bit is an entry into a table that is used to describe and control that feature bit. Each entry in the feature table identifies which bit in the arbitrary precision integer is used to represent the feature, the name of the feature, and a set of bit flags used to control the modification of the feature bit. The bit flags are defined as follows.

One bit flag is called the availability flag and it is used to determine whether or not a feature is available. If this flag is set, or true, then the corresponding feature is 'active' and available to the program. If this flag is not set, or false, then the corresponding feature is ' inactive' and not available to the program even though the code implementing the feature may exist.

The version class has a default feature bit integer that is a class variable and it is used to initialize the feature bits when each class object is instantiated. The default integer is created when the class is first loaded and contains all of the feature bits that are available. This integer is built by looping through the feature table and adding each feature bit to the integer that is marked in the table as available. Regardless of any other bit flags, if the availability flag is not set, then the feature bit is not added to the default integer and none of the methods that manipulate this feature bit will work.

Two other bit flags are called the setable and the resetable flags. If the setable flag is true, it means that it is permissible to set the corresponding feature bit. Otherwise, it is not permissible. The resetable flag is the logical companion to setable. Note that these flags say nothing about the current state of the feature bit, only how it may be manipulated. The two flags taken together define four 'states' that determine how the feature bit may be manipulated.

The main method of the version class is called 'hasFeature'. Each feature is specified in the code by a small positive integer that is, in reality, an index into the feature table. This index is passed to hasFeature which returns true if the specified feature...