Feature Toggles

Feature toggles are boolean switches that you can use to turn certain functionality on or off. You model features by giving them a name and assign them to capabilities.

feature ShowNameInHeading { set Active = false; }

capability Medium {
    link UserInterfaces = ...;

    link Features = ShowNameInHeading;
}

With set Active = false; you define a default value for a feature.

In the web fragment interface component the enumeration [capability-Name]Feature.java is generated.

public enum MediumFeature {

    SHOWNAMEINHEADING(false),
    ;
}

In the Abstract[capability-Name]ManagedBean.java the method
Boolean isFeatureActive(MediumFeature feature) is generated. You call this method in your managed beans to find out whether a feature is ON or OFF. Here is an example.

public String getHeaderPostfix() {
    if (isFeatureActive(MediumFeature.SHOWNAMEINHEADING)) {
        return getHeaderPostfix(this.user.getFirstName(),
                                this.user.getLastName(),
                                this.user.getEmail());
    }

    return "";
}

In the web application component you find a gnerated file
App[Capability-Name]FeatureCustomization.java where you can turn a feature ON like this:

public Boolean isFeatureActive(MediumFeature feature) {
    if (feature != null) {
        switch (feature) {
        case SHOWNAMEINHEADING:
            return Boolean.TRUE;
        }
    }

    return null;
}

Using feature toggles works best for functionality that spans more than one page and that is of a binary nature (ON/OFF). In other cases there are better means for the customization of application functionality:

So please don’t model features like for instance show_input_field_abc, email_input_required or use_special_page_title_for_customer_abc.