Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Do you often work with complex Boolean math? I don't come across it much. In fact the project I inherited is full of
if(true) {
return true;
}
else{
return false;
} -
Jesus said, but let your communication be, Yea, yea; Nay, nay: for whatsoever is more than these is a parity error.
-
Root797534y@AlgoRythm Yeah.
I work in finance (fintech?) and the codebase is quickly heading towards flag hell.
There’s a lot of complicated logic around when to do something, when to show things, etc. and of course the PM always gives complicated conditions, and they are inverses of how I would represent them in code. (And some of the conditions are compound, like `.viable?` means “not closed and not suspended”)
Currently I’m refactoring something that’s a long list of nested ifs/ifelses with various compound conditions, and converting it into a set of functions with guards. So much easier to understand. But this involves simplifying the messy boolean logic trees, and inverting many of the branches.
And ofc writing specs that ensure the logic is correct, including negative tests which involve more inversions.
It’s been fun 😅 -
Hmmm isn't it just simple to understand code if boolean logic actually follows if-else code-like structure.
Maybe you might have a lot of these conditional flags for which combinations may very well be closures/lambdas/whatever.
Edit: nvm your comment just updated for me @Root -
Root797534y@3rdWorldPoison
Imagine, if you will, a world filled with branching logic trees. For this particular tree, all of the various endpoints modify or replace a shared array, or modify data that other endpoints will eventually inject into said array. Determining if the array will have a particular bit of data involves climbing through all of its parent branches, and often traversing the entire tree. Adding new data also involves understanding the entire tree.
Now, imagine a set of boxes with clearly defined rules atop. If the rules are met, the box is opens; if they are not, it remains locked. Constructing the array mentioned above amounts to opening each box in turn and gathering the contents. If you desire a particular bit of data, you need only check its box. Adding new boxes is likewise trivial. -
@Root
As someone who got turned upside down a bit just yesterday with just a handful of true false cases (with a bunch checks for 'not false' and 'is false' and now the same with true ... GUIES STOP) in a row ... that does not sound fun.
On the other hand if it works in the end, does sound really fun. -
@Root nice explaination 10/10. I imagine I won't see the essence of it without understanding the scale of the problem.
Quite interesting to see the approach nonetheless. -
eeee31224yFor complex boolean logic I always consider introducing proper types and leveraging polymorphism instead of extracting functions with guards. But that could be a first step towards getting stuff manageable and testable in smaller units.
-
l0rdkr0n0s24yThat is great I didn’t know WolframAlpha could do that. I have been using Karnaugh Map to simply boolean expressions.
-
@l0rdkr0n0s WolframAlpha is amazing but they do a poor job in marketing and explaining what it can do for you.
And the interface hasn't been updated since they launced the website in 2009. So the appearance may seem dated and scare new user away.
😄 i showed WolframAlpha to a high school student once and he thanked me so much, as he hates math homework. With WolframAlpha homework becomes obsolete as the main skill of today lies in the knowledge where to get knowledge.
Google-fuu, YouTube tutorials, are the essential skills of today.
Related Rants
-
Number031Confession: I am not a dev, I actually work on an IT helpdesk telling people how to turn on their PC's everyda...
-
Lyon26I have a confession to make. I do most of my java coding in comic sans ;-; IT MAKES ME HAPPY FOR SOME REASON
-
redundandundant6Me trying to find a good risotto recipe. Sister-in-law, PhD: What about pumpkin or courgette and salmon? Me: ....
Confession:
I rely on WolframAlpha to simplify Boolean logic a little too much.
random
boolean logic
maybe i should write my own in haskell
confession