We can write If/Else condition in expression rule then why do we need decisions objects in Appian

Certified Associate Developer

We can write If/Else condition in expression rule then why do we need decisions objects in Appian

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer

    Hi, 

    • Readability: Decision objects use a table format, making complex logic easier to understand and maintain than nested if/else statements.
    • Reusability: Decisions can be used in multiple places in your Appian application, reducing code duplication.
    • Scalability: Decision objects handle complex logic with many conditions more effectively than if/else statements.
  • 0
    Certified Lead Developer

    IN execution they are pretty the same, but if you have several if's with same structure and different values, it's better for reusability , maintenance and readability to create a decision table grouping all the decisions in one table.

  • 0
    Certified Lead Developer

    if(), match() and decision tables are very similar, but the details matter.

    In decision tables, you can only use static values for comparing and for the output.

    if() is only good for a single condition. As soon as you need multiple nested condition, code becomes  hard to understand.

    match() is great for comparing one value against multiple conditions and allows you to use dynamic compare operands and return values.

    In my daily work, I use if() most often, followed by match(). Decision tables not so much.

  • 0
    Certified Lead Developer

    I'd say that readability would be the most common reason for using Decisions. But like Stefan, I rarely have a use for them. I'll usually use a!match instead.

  • 0
    Certified Lead Developer
    in reply to Mathieu Drouin

    I think that decision tables can be taken into account when , for example, you have 30 different combinations of your parameters (30 different if's)

    TO be honest, I've only used dt once in Appian, but a lot of times when workin with BRMS

  • Decision objects in Appian offer a structured approach for complex decision-making processes, allowing for better organization and management of business rules. While If/Else conditions in expression rules are useful for simple logic, decision objects provide scalability, reusability, and visibility, facilitating collaboration and maintenance in larger applications.

  • 0
    Certified Senior Developer

    Hello  

    If() - When you are using if for a single condition your code would look much simpler and easier to understand. Also when you are using If() to evaluate multiple conditions that is nested if() it would be difficult to understand the order of evaluation. Also when you pass a null value to If() it would by default consider it to be a false. 

    a!match() -  You can compare multiple conditions against a single value and avoid lot of confusion. Also it would have a whenTrue parameter and a default.

    Decisions -  Similar to decisions but the complete condition sets are predefined and if your condition matches any of the defined patterns in the Decision object then it would return a out else a default.  Easier to read and understand each set of condition. I have mostly used Decisions when a set of logics should return groups or users. would be more static values. 


      <---This would make Decision different from match and If() I guess.

    In practice for simpler logics we would use If() and when you have a huge set of possibilities against a single value we would use a!match() and when you have multiple variables/values to evaluate as a single condition and provide output (Expected values in a scenario which would be predefined in your decision object) we would use decision.

    Hope this helps!

  • 0
    Certified Lead Developer

    I rarely use Decision tables, but the one use case they've proven to be consistently good (or decent) at in my company's Appian system, is when storing relationships to a list of hardcoded ID values, in a manner that's user-friendly enough for some of our business analysts / business owners to look at and understand, and in some cases to go in and update themselves.