Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'd investigate using the Strategy pattern as a means to implement different functionality in different versions of the site. Have a Factory that takes in your configuration and supplies the appropriate code strategy based on it. Each strategy can implement some common interface so that they are interchangeable from the calling class' point of view. This will isolate your changes to implement new strategies to the Factory class, Configuration class, and any new strategy classes that you need to implement to make the change. You could do the same (or similar) with any user controls that need to differ between the different versions.</p> <p>I'll illustrate with pseudocode (that may look suspiciously like C#)</p> <pre><code>public interface ILogoutStrategy { void Logout(); } public abstract class AbstractLogoutStrategy : ILogoutStrategy { public virtual void Logout() { // kill the sesssion } } public class SingleSiteLogoutStrategy : AbstractLogoutStrategy { public void Logout() { base.Logout(); // redirect somewhere } } public class CentralAuthenticationSystemLogoutStrategy : AbstractLogoutStrategy { public void Logout() { base.Logout(); // send a logout request to the CAS // redirect somewhere } } public static class StrategyFactory { public ILogoutStrategy GetLogoutStrategy(Configuration config) { switch (config.Mode) { case Mode.CAS: return new CentralAuthenticationSystemLogoutStrategy(); break; default: case Mode.SingleSite: return new SingleSiteLogoutStrategy(); break; } } } </code></pre> <p>Example usage:</p> <pre><code>ILogoutStrategy logoutStrategy = StrategyFactory.GetLogoutStrategy( config ); logoutStrategy.Logout(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload