Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6327473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:17:10+00:00 2026-05-24T17:17:10+00:00

I’ve been using .Net languages for 4 years. I develop 3 tier and 5

  • 0

I’ve been using .Net languages for 4 years. I develop 3 tier and 5 tier applications using WCF, ASP.NET for web applications, and C# for windows applications. Every time I start a project, business rules and validations are a concern.

Where should I place custom validation rules (button-click events, page load, or in setters/getters within my classes)?

If a project is large and there is just a field that instead of 5 characters should be 7 characters – Why should I rebuild the whole project (or business classes project)?

I think if I had a file that had my custom rules, then when a change is needed I could simply place a new rule in it. I have read some articles on the internet that offer an XML based file for this purpose, but this seems problematic because:

  • No Intellisense and errors in the XML file are very hard to find
  • We have to write custom XML parsers
  • Since this method requires numerous casts, it’s very slow

My Question:

Is there a design pattern or anything else using .NET methods (Reflection, Expression Trees, Lambda Expressions, Dynamics, Runtime Creation of DLLs, etc.) to have dynamic validation using custom rules?


Edit 1)

What about Attributes? Can we use them with Reflection to Custom validations? Can we validate a property according another property(form example P1 should be P2+1) with this approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:17:11+00:00Added an answer on May 24, 2026 at 5:17 pm

    The best way to denote the business rules is in an xml. To take full advantage of this notation, you should start with defining the structure of the rule engine’s data model i.e. answer these questions.

    1. What are the rules?
    2. Can the rules be categorized?
    3. Do the rules contain common properties (attributes) like allowed values, format, etc.?

    Once this is done, create a dummy rules xml and then derive an xml schema based on this xml. The xsd.exe tool can aid you in creating the schema. It is easier to create the schema if you can use tools like Altova XmlSpy.

    As for answers to your specific questions,

    • We can’t using Intellisense and if we have error in XML file it is very hard to find it.

    Once you have the schema in place, Visual Studio provides ample support in creating the xml (including intellisense and validation).

    • We should write a custom xml parsers

    Not required, the XmlSerializer Class provides logic for serialization/deserialization i.e. to convert the rules xml into the rules data model and vice versa.

    • Because this method needs numerous casting ,it’s very slow

    Well, this is a partly valid point when compared to hard coded rules (rules that are embedded into your assembly as classes), but the flexibility of this approach far outweighs any performance demerits. You do not need to rebuild the solution in case there a change in the rules. In most cases, the performance impact is minimal.

    Unless you have a strict performance criteria, the xml approach is the preferred way to implement the rules engine. Remember that the more loosely coupled your architecture is, the higher is the flexibility at runtime but there is negative impact on performance.

    Sample rule

    <RulesEngine>
      <Rules>
        <Rule Id="Rule1">
          <Function>
            <Equals>
              <Property name="Property1" classId="MyClassId"/>
                <Sum>
                  <Property name="Property2" classId="MyClassId"/>
                  <Constant type="UInt16" value="1"/>
                </Sum>
              </Equals>
            </Function>
          </Rule>
        </Rules>
        <Classes>
        <Class name="MyNamespace.MyClass" Id="MyClassId">
          <Property name="Property1" type="UInt16"/>
          <Property name="Property2" type="UInt16"/>
        </Class>
      </Classes>
    </RulesEngine>
    

    The rules engine needs to interpret this rule and deduce the meaning accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.