AboutSQL Server, Analytics, .Net, Machine Learning, R, Python Archives
About Me
Mitch Wheat has been working as a professional programmer since 1984, graduating with a honours degree in Mathematics from Warwick University, UK in 1986. He moved to Perth in 1995, having worked in software houses in London and Rotterdam. He has worked in the areas of mining, electronics, research, defence, financial, GIS, telecommunications, engineering, and information management. Mitch has worked mainly with Microsoft technologies (since Windows version 3.0) but has also used UNIX. He holds the following Microsoft certifications: MCPD (Web and Windows) using C# and SQL Server MCITP (Admin and Developer). His preferred development environment is C#, .Net Framework and SQL Server. Mitch has worked as an independent consultant for the last 10 years, and is currently involved with helping teams improve their Software Development Life Cycle. His areas of special interest lie in performance tuning |
Thursday, July 13, 2006Boolean what? Rules for Simplification
We were having a small dev meeting the other day, someone said something and I replied “…it’s a bit like applying Boolean Algebra or Karnaugh maps” which resulted in several blank looks. Thinking they had misheard (my diction is not always the clearest) I repeated the statement and gave the example of applying De Morgan’s laws. These are applied by negating the individual terms, changing the AND’s=OR’s and the OR’s=AND ‘s and then negating the whole expression e.g.
A + B = NOT ( (NOT A) . (NOT B)) A . B = NOT ((NOT A) + (NOT B)) where '.' = AND, '+' = OR Now some of you are probably saying what does this have to do with my day-to-day job? Well, applying these simplification rules can be very useful for simplying ‘if’ logic. I’m not a big fan of those ‘if’ statements that descend 15 levels deep! In fact, I always try and simplify logic to make it more understandable (no more than 3 or 4 nestings is great). I have seen some shockers: a few years ago, one coder whose code was outside my jurisiction would mangle huge, completely unfathomable nested if’s. She just did not get why this was totally wrong. Sigh! [Note: Karnaugh maps are more usually used by electrical engineers to reduce the number of gates required to implement some specific boolean logic.] |
ContactMSN, Email: mitch døt wheat at gmail.com LinksFavorites
Blogs |