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

  • SEARCH
  • Home
  • 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 6909547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:42:13+00:00 2026-05-27T08:42:13+00:00

This question could be subjective. I’m not sure if it belongs here or on

  • 0

This question could be subjective. I’m not sure if it belongs here or on Programmers

Say I have a data type, X (think of business objects constructed from a relational database). My end goal is represent many instances of this type in a table for a report, with each instance under one of a few different headings.

The heading to display the object under is selected based on arbitrary logic handed down from management, which anybody who’s done corporate software development will be familiar with:

Examples:

If the instance has a FooID of 6 and a BarFactor of < 0.5, place it under the "Borked" heading.

or

If the Weight is > 0, and the CreatedDate is before Midnight but after 3PM, and today is not the 3rd Wednesday of the month, the object should be categorised as "Fluffy".

My question: Is there a common idiom for taking an instance of X, applying a potentially headache-inducing amount of logic to the state of the instance and getting a category/string/arbitrary value from the result of that logic?


My ideas so far have been:

  1. A function which takes an X and returns a String. I could easily see this turning into a Megamoth, and a b***** to maintain as requirements are constantly modified.

  2. Define a Heading abstract type, and a factory function which gives me an instance of Heading with the ToString method correctly overloaded. I think this technique will be plagued by the same issues as idea no. 1.

  3. A hierarchy of functions, each splitting the problem up a little further until we arrive at the correct heading.

For example:

public String GetHeading(X x) 
{
    if (x.Weight > 0)
        return WeightGreaterThanZero(x);
    else if (x.Weight < 0)
        return WeightLessThanZero(x);
    else
        return WeightIsZero(x);
}

The three “Weight” functions would test further conditions until we arrive at a value. The problem I see here is that we need to track which function called which. The FooIDIs6 function needs to know whether it was called by WeightIsZero or some other function, otherwise any preceding decisions are potentially meaningless. We end up with something like WeightIsGreaterThanZero_FooIDIs6_GrandmotherIsOlderThan100 etc. etc.

  • 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-27T08:42:14+00:00Added an answer on May 27, 2026 at 8:42 am

    I’m not sure that this completely applies to what you are trying to accomplish, but whenever we encounter this type of “fun”, we end up providing the business users a user interface to define their rules, then just write enough code to apply the rules to the specific objects.

    For example, in one of our applications, we allow the user to specify a set of conditions that, when evaluated to true, will produce a user-defined output.

    To do this, we store one record in the database for each portion of the IF statement. Each record specifies the property name in the class, the comparison action (<, =, <>, etc), the comparison value, whether or not the statement begins or ends a group (i.e. parens), and how the current statement is joined with the next (AND or OR).

    So you would have

    Heading Record (Parent record, which defines the heading to be used)
      Heading Selector (Child records which define the if statement)
    

    We can also support user-defined priorities in the parent record so that if a given record has multiple matches, it is the user’s responsibility to determine the best match through the proper application of priorities.

    At run time, you just build a statement to evaluate the conditions as entered by the user. We use reflection so that we don’t have to hard-code property names.

    In addition, the same configuration code can be used to generate SQL statements in the cases where it is more appropriate to perform the selection logic in SQL.

    We have used this mechanism extensively and have found it to be a very powerful approach to meeting the frequent and varied demands of our customers.

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

Sidebar

Related Questions

This could be a borderline advertisement, not to mention subjective, but the question is
Sorry if this question is somewhat subjective. I am new to 'could store', 'distributed
I was asked this question and could not come up with the answer. Is
I have this question: How could I call a codebehind method from jquery? I
This question is related to Java Refuses To Start - Could Not Resrve Enough
Firstly I appreciate that this question could be seen as subjective but I strongly
I know this could be seen as subjective off-the-cuff (thus a poor question), but
I know this could be a subjective question, but I want to know your
This question could be a can of worms, but I've always wondered if it
I suppose this question could just as easily be applied to PHP with regard

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.