Day 6 - Let's extract a compound conditional

Really like this challenge. Unfortunately I wasn’t able to get my change completed in the 20 minutes. I found a method with a long conditional (8 different clauses and'd together), did the refactor, then discovered that the method didn’t have any unit tests in place. Started working on those, but wasn’t able to get it done in the 20 minutes.

Edit: so I went back later and completed them & put the whole shebang up for review. Was really interesting as it turned out the conditional I extracted had ~14 clauses and was duplicated verbatim in another spot, so I could just replace that with the method call. Happy side benefits!

One note: my language (Python) wasn’t so easy to find places to do this, as the boolean operators in Python are and and or not && and ||. Ended up doing a grep for and and restricting to only Python source files, and even then finding good candidates wasn’t as easy as one might think.

3 Likes