Sitemap
Business4s Blog

Space for the articles related to business4s.org community

Announcing Decisions4s: When Ifs Are Not Enough

3 min readAug 12, 2024

--

What is Decisions4s?

val allowMerging =
if (numOfApprovals > 0) {
if (isTargetBranchProtected && (numOfApprovals > 1 || isUserAdmin)) true
else !isTargetBranchProtected
} else if (isUserAdmin) true
else false
val notifyUnusualAction = numOfApprovals == 0 && allowMerging
Rule(
matching = Input(
numOfApprovals = it > 0,
isTargetBranchProtected = it.isFalse,
authorIsAdmin = it.catchAll,
),
output = Output(allowMerging = true, notifyUnusualAction = false),
)
decisionTable.evaluateFirst(
Input(
numOfApprovals = 2,
isTargetBranchProtected = true,
authorIsAdmin = false,
),
)
Evaluation diagnostics for "PullRequestDecision"
Hit policy: First
Result: Some(Output(true,false))
Input:
numOfApprovals: 2
isTargetBranchProtected: true
authorIsAdmin: false
Rule 0 [✗]:
numOfApprovals [✓]: > 0
isTargetBranchProtected [✗]: false
authorIsAdmin [✓]: -
== ✗
Rule 1 [✓]:
numOfApprovals [✓]: > 1
isTargetBranchProtected [✓]: true
authorIsAdmin [✓]: -
== Output(true,false)

Aren’t If Expressions Enough?

Boring Technical Solution To An Important Human Problem

Summary

--

--

Voytek Pituła
Voytek Pituła

Written by Voytek Pituła

Generalist. An absolute expert in faking expertise. Claimant to the title of The Laziest Person in Existence. Staff Engineer @ SwissBorg.

Responses (1)