locked
Extending Factory Pattern RRS feed

  • Question

  • User-574293449 posted

    Hi,

      I have a deployment class which consists of set of properties and methods. Based on the industry type i need to load the corresponding industry class. For this i used Factory pattern. I think my selection is right. please let me know if i am wrong. My implementation is below

    public interface IDeployment
        {
    
            /// <summary>Deployment status</summary>
            /// <value>Get deployment status of the client</value>
            bool IsDeployed { get; }
    
            /// <summary>
            /// Licence Type
            /// <list type="number">
            /// <item> 0
            /// <description>No License</description>
            /// </item>
            /// <item> 1
            /// <description>Time bound</description>
            /// </item>
            /// <item> 2
            /// <description>License Certificate</description>
            /// </item>
            /// </list>
            /// </summary>
            /// <value>Get license type of the client</value>
            int LicenseType { get; }
    
            /// <summary>
            /// Licence Validation status
            /// </summary>
            /// <value>Get license validation status</value>
            bool IsLicenseValidation { get; }
    
            /// <summary>
            /// Item list to block the Configuration Management Panel
            /// </summary>
            /// <returns></returns>
            System.Collections.ArrayList ConfigurationManagement();
    
     
        }
    
        public abstract class DeploymentFactory
        {
            public abstract IDeployment GetDeployment(string industry);
    
        }
    
        public class DeploymentClass : DeploymentFactory
        {
    
            public override IDeployment GetDeployment(string industry)
            {
                switch(industry)
                {
                    case "Assembly":
                        return new Assembly();
                    case "Machining":
                        return new Machining();
                    case "Pharma":
                        return new Pharma();
                    default:
                        throw new ArgumentException("Invalid Industry", industry);
                }
            }
    
        }
    
    public class Assembly : IDeployment
        {
    
            public bool IsDeployed
            {
                get { return true; }
            }
    
            public int LicenseType
            {
                get { return 2; }
            }
    
            public bool IsLicenseValidation
            {
                get { return true; }
            }
    
           
            public System.Collections.ArrayList ConfigurationManagement()
            {
                ArrayList arr_BlockList = new ArrayList();
    
                return arr_BlockList;
            }
    
          }

    Now some clients have multipe indutry combining Assembly and Machining. When i create a new deployment class it combines Assembly and Machine. Actually this combination of industry is Discrete. How to extent this deployment implementation to handle these types of groups. I am thinking for Abstract Factory. But i dnont know how to implement. I read articles and one give any combination but not like grouping. i am confused. Kindly give a better apporach for this


     But here only Assembly and Machining can be grouped togother. All other industry cannot be clubbed to one company. So create a new class with Discrere is correct solution or any pattern helps here like Facade?

     

    Thursday, January 16, 2014 3:05 AM

All replies