Normalizing logic

7 views
Skip to first unread message

Mike Austin

unread,
Apr 27, 2026, 2:50:12 PM (3 days ago) Apr 27
to PiLuD
I often come across logic that could be normalized but question if it makes it clearer.

if (targetSprintId === sourceSprintId ? targetItemId !== sourceItemId : true) { ... }

It a little awkward with the ternary, but you see that *ItemId is related to the the sprint ids being equal.

if (targetSprintId !== sourceSprintId || targetItemId !== sourceItemId) { ... }

This is more "normalized" you could say, since *ItemIds are only relevant if the sprint ids are equal. But does that require extra brain load? I have to think in negative terms first.

jido

unread,
Apr 28, 2026, 6:16:40 PM (2 days ago) Apr 28
to PiLuD
Well, this example should be written:

if not (targetSprintId === sourceSprintId && targetItemId === sourceItemId) { ... }

As you say, it is easier for the brain to apply the negative at the end.

Mike Austin

unread,
Apr 29, 2026, 11:34:30 AM (21 hours ago) Apr 29
to PiLuD
Perfect! I literally didn't see the !=== || !== pattern because I wasn't looking at the big picture.

I wonder if there's an online logic tool where it can reduce complex boolean logic, and explain the logic (tree?). There are similar tools for Regular Expressions for example  regex101: build, test, and debug regex.
Reply all
Reply to author
Forward
0 new messages