Skip to content

Implement strategy design pattern to enhance onboarding code

Summary

To increase readability and future maintenance of the onboarding area. We should start to implement some ruby design patterns.

In this case the desired design pattern will be the strategy pattern.

Solution

This might be the way it looks:

class TrialRegistration
  def redirect_to_company_form?
    true
  end
end

class FreeRegistration
  def redirect_to_company_form?
    false
  end
end

class OnboardingStatus
  delegate :redirect_to_company_form?, to: :@registration_type
end
Edited by Doug Stull