in C#.NET how to better design classes and use design pattern to my situationHow to get the type of T from a member of a generic class or method?Is it ok to use the same interface definition but provide different behaviour?How to get the list of properties of a class?Custom Validation Attribute is not called ASP.NET MVCquestion about linq select and ToList()How to use reflection to determine if a class locally implements an interface?How can I access members of a private abstract to class for read-only purposes in a public class?Initializing /Accessing Dynamic objects implementing a single interfaceWhy not inherit from List<T>?Is it ok to have the same field names in abstract class and interface?

Does this website provide consistent translation into Wookiee?

Why is it wrong to *implement* myself a known, published, widely believed to be secure crypto algorithm?

Two (probably) equal real numbers which are not proved to be equal?

How to adjust Venn Diagram for A^c and A - B

Sprout Reports plugin - How to output a Matrix field into a row

What are my options legally if NYC company is not paying salary?

Examples where existence is harder than evaluation

Add elements inside Array conditionally in JavaScript

Names of the Six Tastes

Sed operations are not working or might i am doing it wrong?

Are there vaccine ingredients which may not be disclosed ("hidden", "trade secret", or similar)?

GLM: Modelling proportional data - account for variation in total sample size

Is it safe to keep the GPU on 100% utilization for a very long time?

logo selection for poster presentation

Capturing the entire webpage with WebExecute's CaptureImage

When I add a cylinder, it doesn't even show up on my screen at all

Can I bring back Planetary Romance as a genre?

Whose birthyears are canonically established in the MCU?

History: Per Leviticus 19:27 would the apostles have had corner locks ala Hassidim today?

Is there an idiom that means "revealing a secret unintentionally"?

How do I give a darkroom course without negatives from the attendees?

What is the Ancient One's mistake?

Is there an application which does HTTP PUT?

Why is there a cap on 401k contributions?



in C#.NET how to better design classes and use design pattern to my situation


How to get the type of T from a member of a generic class or method?Is it ok to use the same interface definition but provide different behaviour?How to get the list of properties of a class?Custom Validation Attribute is not called ASP.NET MVCquestion about linq select and ToList()How to use reflection to determine if a class locally implements an interface?How can I access members of a private abstract to class for read-only purposes in a public class?Initializing /Accessing Dynamic objects implementing a single interfaceWhy not inherit from List<T>?Is it ok to have the same field names in abstract class and interface?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















This is for desktop app with WPF.



Point 1 - I have create(write logic for) different types of rules, and these rules fall under 5 types of categories (AbsolutePositionalAccuracy, AttributeValidation, DataCompletion, Logical, TopologicalIntegrity). and there categories are same for each bundles. here bundles are grouping of different type of data. there can be around 10 types of bundles.



Point 2 - I have data which shall be validated against rules mentioned above. whenever data is failing by not conforming with any of the rules, it should be flagged with details e.g. what rule failed, that rule fall under which category, under which bundle, and on which data it failed etc.



Point 3 - in UI side, I will give options to user, to choose, which rule he would like to check for. user can choose multiple rules under any category, under any bundle.



  1. Bundle 1

    • Absolute Positional Accuracy :

      • Rule1


    • Attribute Validation

      • Rule1

      • Rule2


    • Data Completion

      • Rule1

      • Rule2

      • Rule3


    • Logical

      • Rule1

      • Rule2

      • Rule3


    • Topological Integrity

      • Rule1

      • Rule2

      • Rule3

      • Rule4

      • Rule5

      • Rule6

      • Rule7



  2. Bundle 2

    • Absolute Positional Accuracy :

      • Rule1

      • Rule2

      • Rule3


    • Attribute Validation

      • Rule1

      • Rule2


    • Data Completion

      • Rule1

      • Rule2

      • Rule3

      • Rule4


    • Logical

      • Rule1

      • Rule3


    • Topological Integrity

      • Rule1

      • Rule2

      • Rule3

      • Rule4

      • Rule5

      • Rule6

      • Rule7

      • Rule8

      • Rule9

      • Rule10



Number of rules varies from categories to categories. some categories may have 5 rules, some may have 20, or some may have 40 rules.



Once user has selected, I will pass this selection to a class where actual rule will be executed, and result will be returned to UI.



**Question -1 ** I want to know, for this situation, what kind of framework should i use, e.g. Factory pattern (to create rules based on their bundles and categories and rule selection). or is there any other better ways so that if in future i will have to add more new rules, under any of the categories, its flexible, and i will be able to do that with changes at minimum places in my code base.



**Question -1 ** How can i avoid multiple if conditions or Switch case statement, when deciding which rule to execute, based on user's selection(BundleType, rule category, and actual rule). because I may have total 100+ rules. Is there any other alternative, e.g. using reflection. or other betterway.



For Point 1 - I have created an Interface IBaseRule which has execute() method, and some other properties describing ruleType, RuleSubType etc.
and also created an Abstract Class(derived from IBaseRule interface) for each Category of the RuleType (only RuleType property is implemented here, rest are mentioned as abstract to be implemented by concrete RuleClasses for respective categories. ):



  1. public abstract class AbsolutePositionalAccuracyRule : IBaseRule

  2. public abstract class AttributeValidationRule: IBaseRule

  3. public abstract class DataCompletionRule : IBaseRule

  4. public abstract class LogicalRule : IBaseRule

  5. public abstract class TopologicalIntegrityRule : IBaseRule


// Interface

public interface IBaseRule

string RuleType get;
string RuleSubType get;
string ShortDescription get;
string LongDescription get;

IRuleErrorCollection Execute();



// Abstract Class

public abstract class AbsolutePositionalAccuracyRule : IBaseRule

public string RuleType

get return "qcRuleTypeAbsolutePositionalAccuracy";


public abstract string RuleSubType

get;


public string ShortDescription

get return "Check for the positional accuracy";


public string LongDescription

get return "Check for the positional accuracy";


public abstract IRuleErrorCollection Execute();



// Concrete Class

public class CheckProjectionRule : AbsolutePositionalAccuracyRule//, IBaseRule

public static string Alias get return "Check Projection";

private string _bundleName;
private IFeatureClass _pFeatClass;
private int _targetSrId;

public CheckProjectionRule(string bundleName, IFeatureClass featureClass, int targetSrId)

_bundleName = bundleName;
_pFeatClass = featureClass;
_targetSrId = targetSrId;


override public string RuleSubType

get return "Check Projection Rule";


override public IRuleErrorCollection Execute()

RuleErrorCollection errorRuleColl = new RuleErrorCollection();


errorRuleColl.Add("Error Details");
return errorRuleColl;












share|improve this question




























    0















    This is for desktop app with WPF.



    Point 1 - I have create(write logic for) different types of rules, and these rules fall under 5 types of categories (AbsolutePositionalAccuracy, AttributeValidation, DataCompletion, Logical, TopologicalIntegrity). and there categories are same for each bundles. here bundles are grouping of different type of data. there can be around 10 types of bundles.



    Point 2 - I have data which shall be validated against rules mentioned above. whenever data is failing by not conforming with any of the rules, it should be flagged with details e.g. what rule failed, that rule fall under which category, under which bundle, and on which data it failed etc.



    Point 3 - in UI side, I will give options to user, to choose, which rule he would like to check for. user can choose multiple rules under any category, under any bundle.



    1. Bundle 1

      • Absolute Positional Accuracy :

        • Rule1


      • Attribute Validation

        • Rule1

        • Rule2


      • Data Completion

        • Rule1

        • Rule2

        • Rule3


      • Logical

        • Rule1

        • Rule2

        • Rule3


      • Topological Integrity

        • Rule1

        • Rule2

        • Rule3

        • Rule4

        • Rule5

        • Rule6

        • Rule7



    2. Bundle 2

      • Absolute Positional Accuracy :

        • Rule1

        • Rule2

        • Rule3


      • Attribute Validation

        • Rule1

        • Rule2


      • Data Completion

        • Rule1

        • Rule2

        • Rule3

        • Rule4


      • Logical

        • Rule1

        • Rule3


      • Topological Integrity

        • Rule1

        • Rule2

        • Rule3

        • Rule4

        • Rule5

        • Rule6

        • Rule7

        • Rule8

        • Rule9

        • Rule10



    Number of rules varies from categories to categories. some categories may have 5 rules, some may have 20, or some may have 40 rules.



    Once user has selected, I will pass this selection to a class where actual rule will be executed, and result will be returned to UI.



    **Question -1 ** I want to know, for this situation, what kind of framework should i use, e.g. Factory pattern (to create rules based on their bundles and categories and rule selection). or is there any other better ways so that if in future i will have to add more new rules, under any of the categories, its flexible, and i will be able to do that with changes at minimum places in my code base.



    **Question -1 ** How can i avoid multiple if conditions or Switch case statement, when deciding which rule to execute, based on user's selection(BundleType, rule category, and actual rule). because I may have total 100+ rules. Is there any other alternative, e.g. using reflection. or other betterway.



    For Point 1 - I have created an Interface IBaseRule which has execute() method, and some other properties describing ruleType, RuleSubType etc.
    and also created an Abstract Class(derived from IBaseRule interface) for each Category of the RuleType (only RuleType property is implemented here, rest are mentioned as abstract to be implemented by concrete RuleClasses for respective categories. ):



    1. public abstract class AbsolutePositionalAccuracyRule : IBaseRule

    2. public abstract class AttributeValidationRule: IBaseRule

    3. public abstract class DataCompletionRule : IBaseRule

    4. public abstract class LogicalRule : IBaseRule

    5. public abstract class TopologicalIntegrityRule : IBaseRule


    // Interface

    public interface IBaseRule

    string RuleType get;
    string RuleSubType get;
    string ShortDescription get;
    string LongDescription get;

    IRuleErrorCollection Execute();



    // Abstract Class

    public abstract class AbsolutePositionalAccuracyRule : IBaseRule

    public string RuleType

    get return "qcRuleTypeAbsolutePositionalAccuracy";


    public abstract string RuleSubType

    get;


    public string ShortDescription

    get return "Check for the positional accuracy";


    public string LongDescription

    get return "Check for the positional accuracy";


    public abstract IRuleErrorCollection Execute();



    // Concrete Class

    public class CheckProjectionRule : AbsolutePositionalAccuracyRule//, IBaseRule

    public static string Alias get return "Check Projection";

    private string _bundleName;
    private IFeatureClass _pFeatClass;
    private int _targetSrId;

    public CheckProjectionRule(string bundleName, IFeatureClass featureClass, int targetSrId)

    _bundleName = bundleName;
    _pFeatClass = featureClass;
    _targetSrId = targetSrId;


    override public string RuleSubType

    get return "Check Projection Rule";


    override public IRuleErrorCollection Execute()

    RuleErrorCollection errorRuleColl = new RuleErrorCollection();


    errorRuleColl.Add("Error Details");
    return errorRuleColl;












    share|improve this question
























      0












      0








      0








      This is for desktop app with WPF.



      Point 1 - I have create(write logic for) different types of rules, and these rules fall under 5 types of categories (AbsolutePositionalAccuracy, AttributeValidation, DataCompletion, Logical, TopologicalIntegrity). and there categories are same for each bundles. here bundles are grouping of different type of data. there can be around 10 types of bundles.



      Point 2 - I have data which shall be validated against rules mentioned above. whenever data is failing by not conforming with any of the rules, it should be flagged with details e.g. what rule failed, that rule fall under which category, under which bundle, and on which data it failed etc.



      Point 3 - in UI side, I will give options to user, to choose, which rule he would like to check for. user can choose multiple rules under any category, under any bundle.



      1. Bundle 1

        • Absolute Positional Accuracy :

          • Rule1


        • Attribute Validation

          • Rule1

          • Rule2


        • Data Completion

          • Rule1

          • Rule2

          • Rule3


        • Logical

          • Rule1

          • Rule2

          • Rule3


        • Topological Integrity

          • Rule1

          • Rule2

          • Rule3

          • Rule4

          • Rule5

          • Rule6

          • Rule7



      2. Bundle 2

        • Absolute Positional Accuracy :

          • Rule1

          • Rule2

          • Rule3


        • Attribute Validation

          • Rule1

          • Rule2


        • Data Completion

          • Rule1

          • Rule2

          • Rule3

          • Rule4


        • Logical

          • Rule1

          • Rule3


        • Topological Integrity

          • Rule1

          • Rule2

          • Rule3

          • Rule4

          • Rule5

          • Rule6

          • Rule7

          • Rule8

          • Rule9

          • Rule10



      Number of rules varies from categories to categories. some categories may have 5 rules, some may have 20, or some may have 40 rules.



      Once user has selected, I will pass this selection to a class where actual rule will be executed, and result will be returned to UI.



      **Question -1 ** I want to know, for this situation, what kind of framework should i use, e.g. Factory pattern (to create rules based on their bundles and categories and rule selection). or is there any other better ways so that if in future i will have to add more new rules, under any of the categories, its flexible, and i will be able to do that with changes at minimum places in my code base.



      **Question -1 ** How can i avoid multiple if conditions or Switch case statement, when deciding which rule to execute, based on user's selection(BundleType, rule category, and actual rule). because I may have total 100+ rules. Is there any other alternative, e.g. using reflection. or other betterway.



      For Point 1 - I have created an Interface IBaseRule which has execute() method, and some other properties describing ruleType, RuleSubType etc.
      and also created an Abstract Class(derived from IBaseRule interface) for each Category of the RuleType (only RuleType property is implemented here, rest are mentioned as abstract to be implemented by concrete RuleClasses for respective categories. ):



      1. public abstract class AbsolutePositionalAccuracyRule : IBaseRule

      2. public abstract class AttributeValidationRule: IBaseRule

      3. public abstract class DataCompletionRule : IBaseRule

      4. public abstract class LogicalRule : IBaseRule

      5. public abstract class TopologicalIntegrityRule : IBaseRule


      // Interface

      public interface IBaseRule

      string RuleType get;
      string RuleSubType get;
      string ShortDescription get;
      string LongDescription get;

      IRuleErrorCollection Execute();



      // Abstract Class

      public abstract class AbsolutePositionalAccuracyRule : IBaseRule

      public string RuleType

      get return "qcRuleTypeAbsolutePositionalAccuracy";


      public abstract string RuleSubType

      get;


      public string ShortDescription

      get return "Check for the positional accuracy";


      public string LongDescription

      get return "Check for the positional accuracy";


      public abstract IRuleErrorCollection Execute();



      // Concrete Class

      public class CheckProjectionRule : AbsolutePositionalAccuracyRule//, IBaseRule

      public static string Alias get return "Check Projection";

      private string _bundleName;
      private IFeatureClass _pFeatClass;
      private int _targetSrId;

      public CheckProjectionRule(string bundleName, IFeatureClass featureClass, int targetSrId)

      _bundleName = bundleName;
      _pFeatClass = featureClass;
      _targetSrId = targetSrId;


      override public string RuleSubType

      get return "Check Projection Rule";


      override public IRuleErrorCollection Execute()

      RuleErrorCollection errorRuleColl = new RuleErrorCollection();


      errorRuleColl.Add("Error Details");
      return errorRuleColl;












      share|improve this question














      This is for desktop app with WPF.



      Point 1 - I have create(write logic for) different types of rules, and these rules fall under 5 types of categories (AbsolutePositionalAccuracy, AttributeValidation, DataCompletion, Logical, TopologicalIntegrity). and there categories are same for each bundles. here bundles are grouping of different type of data. there can be around 10 types of bundles.



      Point 2 - I have data which shall be validated against rules mentioned above. whenever data is failing by not conforming with any of the rules, it should be flagged with details e.g. what rule failed, that rule fall under which category, under which bundle, and on which data it failed etc.



      Point 3 - in UI side, I will give options to user, to choose, which rule he would like to check for. user can choose multiple rules under any category, under any bundle.



      1. Bundle 1

        • Absolute Positional Accuracy :

          • Rule1


        • Attribute Validation

          • Rule1

          • Rule2


        • Data Completion

          • Rule1

          • Rule2

          • Rule3


        • Logical

          • Rule1

          • Rule2

          • Rule3


        • Topological Integrity

          • Rule1

          • Rule2

          • Rule3

          • Rule4

          • Rule5

          • Rule6

          • Rule7



      2. Bundle 2

        • Absolute Positional Accuracy :

          • Rule1

          • Rule2

          • Rule3


        • Attribute Validation

          • Rule1

          • Rule2


        • Data Completion

          • Rule1

          • Rule2

          • Rule3

          • Rule4


        • Logical

          • Rule1

          • Rule3


        • Topological Integrity

          • Rule1

          • Rule2

          • Rule3

          • Rule4

          • Rule5

          • Rule6

          • Rule7

          • Rule8

          • Rule9

          • Rule10



      Number of rules varies from categories to categories. some categories may have 5 rules, some may have 20, or some may have 40 rules.



      Once user has selected, I will pass this selection to a class where actual rule will be executed, and result will be returned to UI.



      **Question -1 ** I want to know, for this situation, what kind of framework should i use, e.g. Factory pattern (to create rules based on their bundles and categories and rule selection). or is there any other better ways so that if in future i will have to add more new rules, under any of the categories, its flexible, and i will be able to do that with changes at minimum places in my code base.



      **Question -1 ** How can i avoid multiple if conditions or Switch case statement, when deciding which rule to execute, based on user's selection(BundleType, rule category, and actual rule). because I may have total 100+ rules. Is there any other alternative, e.g. using reflection. or other betterway.



      For Point 1 - I have created an Interface IBaseRule which has execute() method, and some other properties describing ruleType, RuleSubType etc.
      and also created an Abstract Class(derived from IBaseRule interface) for each Category of the RuleType (only RuleType property is implemented here, rest are mentioned as abstract to be implemented by concrete RuleClasses for respective categories. ):



      1. public abstract class AbsolutePositionalAccuracyRule : IBaseRule

      2. public abstract class AttributeValidationRule: IBaseRule

      3. public abstract class DataCompletionRule : IBaseRule

      4. public abstract class LogicalRule : IBaseRule

      5. public abstract class TopologicalIntegrityRule : IBaseRule


      // Interface

      public interface IBaseRule

      string RuleType get;
      string RuleSubType get;
      string ShortDescription get;
      string LongDescription get;

      IRuleErrorCollection Execute();



      // Abstract Class

      public abstract class AbsolutePositionalAccuracyRule : IBaseRule

      public string RuleType

      get return "qcRuleTypeAbsolutePositionalAccuracy";


      public abstract string RuleSubType

      get;


      public string ShortDescription

      get return "Check for the positional accuracy";


      public string LongDescription

      get return "Check for the positional accuracy";


      public abstract IRuleErrorCollection Execute();



      // Concrete Class

      public class CheckProjectionRule : AbsolutePositionalAccuracyRule//, IBaseRule

      public static string Alias get return "Check Projection";

      private string _bundleName;
      private IFeatureClass _pFeatClass;
      private int _targetSrId;

      public CheckProjectionRule(string bundleName, IFeatureClass featureClass, int targetSrId)

      _bundleName = bundleName;
      _pFeatClass = featureClass;
      _targetSrId = targetSrId;


      override public string RuleSubType

      get return "Check Projection Rule";


      override public IRuleErrorCollection Execute()

      RuleErrorCollection errorRuleColl = new RuleErrorCollection();


      errorRuleColl.Add("Error Details");
      return errorRuleColl;









      c# api-design






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 7:34









      Ravindra SinghRavindra Singh

      92




      92






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311646%2fin-c-net-how-to-better-design-classes-and-use-design-pattern-to-my-situation%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311646%2fin-c-net-how-to-better-design-classes-and-use-design-pattern-to-my-situation%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript