Clearer Conditionals using De Morgan's Laws
robots.thoughtbot.com
Clearer Conditionals using De Morgan's Laws
1–10 of 82 posts
Re: Clearer Conditionals using De Morgan's Laws
#2Good naming conventions are pretty key here. My guess is the original writer of that code had used those in something else entirely, then reused those methods in a new method so he wouldn't have to rewrite.
I always feel like it's better to positively name Boolean values, personally, but I know everyone is different.
Re: Clearer Conditionals using De Morgan's Laws
#3Cool to see De Morgan's Laws used at a high level. But the real takeaway: rewrite your conditional until it makes sense.
Re: Clearer Conditionals using De Morgan's Laws
#4More widespread knowledge of all the other classical deductive logical equivalences can make program syntax clearer, too. :-)
Re: Clearer Conditionals using De Morgan's Laws
#5Alternative title: Why a CS degree is worthwhile even if you're a web developer.
Re: Clearer Conditionals using De Morgan's Laws
#6[deleted]
Re: Clearer Conditionals using De Morgan's Laws
#7Cool to see De Morgan's Laws used at a high level. But the real takeaway: rewrite your conditional until it makes sense.
Or conversely that it is better to write affirmative conditionals rather than negative conditionals. I always find reading the affirmative ones much easier, as I have always found working in positive logic easier than work with negative logic circuits.
Re: Clearer Conditionals using De Morgan's Laws
#8[deleted]
Why OR doesn't short circuit?
Re: Clearer Conditionals using De Morgan's Laws
#9[deleted]
Huh? OR will short-circuit if the first element is true in every language I have ever seen (barring ones that don't short circuit at all).
Re: Clearer Conditionals using De Morgan's Laws
#10The distributivity law is also really helpful for simplifying conditionals. http://en.wikipedia.org/wiki/Boolean_algebra#Monotone_laws