Feature Release Management

Git’s cheap branching and merging ability coupled with Git Flow makes software feature development process a lot easier. However product development is only 1 piece of the puzzle when it comes down to feature release. It’s almost certain that when we release a feature, there will be involvements from support/sales/marketing team. Feature code ready simply doesn’t mean release ready. Some may say, why not just keep the non-released feature code in the Git feature branch… I personally don’t like keeping feature branches long-lived and prefer quick merge-backs. This leads to the question, how can we decouple product development code release and product feature release.

Since knowing that the feature toggle requirement is all on UI side for now, I quickly rolled up my sleeves and hacked together a solution.

First create a features model and back it up with a DB table (yes, it’s the Rails way …). The only significant method is the class method feature_map, which returns me a hash of active features.

class EnvisioFeature < ActiveRecord::Base

  attr_accessible :name,
                  :active,
                  :active_status_changed_at

  validates :name, presence: true, uniqueness: true

  def self.feature_map
    where(active: true).pluck(:name, :active).to_h.symbolize_keys
  end

end

Next up, create a plain Ruby class with a class method get_map, which does a cache fetch on a given hash key.

class EnvisioFeatureMap

  def self.get_map
    Rails.cache.fetch('envisio-features') do
      EnvisioFeature.feature_map
    end
  end

end

Then, I created a couple of helper methods as such

module Corporate
  module EnvisioHelper

    def envisio_show(feature_name, &block)
      if EnvisioFeatureMap.get_map.has_key?(feature_name.to_sym)
        capture(&block)
      end
    end

    def envisio_alternative(feature_name, &block)
      unless EnvisioFeatureMap.get_map.has_key?(feature_name.to_sym)
        capture(&block)
      end
    end

  end
end

Last, in my (HAML) view files, I can just wrap the feature related view code inside the envisio_show or envisio_alternative helper methods like this

= envisio_show :feature_one do
  Awesome feature one

  = envisio_show :feature_one_dot_one do
    Some more enhancement for feature one

= envisio_alternative :feature_one do
  Feature one coming soon

That’s it. The view files are still declaritive without if/else checks.

Of course, there’s an admin only control panel, where administrators can signin to and toggle on/off features without involvement from development team.

Published: 2014-05-27
blog comments powered by Disqus