Conditionals in Real Life and IFTTT

Posted by Amanda Murphy on August 24, 2018

I have to admit that logic and conditionals are currently the aspects of programming that come most easily to me. For those who are having a more difficult time with logic and conditionals, I’m going to provide a few real life scenarios that make the concepts a little easier to digest.

I’ve always been the kind of person who can make anything happen as long as I have a plan. My husband came home one day from his position as a government contractor and told me, “I can’t do this anymore.” I was eight months pregnant, and I said, “Okay.”

We came up with a series of plans, and started to pursue our first choice. Our plan was a lot like what we study about logic and conditionals:

def master_plan
     if we_receive_a_job_offer_here
          accept job offer here
     elsif we_receive_a_job_offer_elsewhere
          accept job elsewhere && move
     elsif apply_for_second_degree_here
          go to school here
     elsif apply_for_second_degree_elsewhere
          go to school && move
     elsif work_until_next_semester
          work until next semester && apply for next semester
     else move_in_with_mother_in_law_temporarily
          move && pick up drinking habit
     end
end

Plan A was to look for jobs in the area, but if Plan A didn’t work out, we’d move on to Plan B–to look for jobs in other locations. If Plan B didn’t work out we would move to Plan C, then Plan D, then Plan E, etc.

Luckily in this case, we decided our priority was getting my husband back to school for a second degree so he could restart his career–we both graduated as creative writing majors and are now pursuing careers in the tech field. (Side note, this was his first week at Indiana University’s Human-Computer Interaction and Design master’s program–so congratulations to him!) We ended up moving from Alabama to Indiana last fall, and although it’s been a challenging year, we’re sure this was the best decision.

I have a second example that you can gain real hands on experience with IFTTT–If This, Then That, which is a website which connects your apps and devices. It’s a free program, so I would recommend signing up and trying it out. (It’s been several years since I’ve used it, so I’m not sure what it can do these days.)

When I first used IFTTT in 2014, it had the capability of sending you texts every time someone commented on a social media post, or every time a friend posted on their Facebook wall. Today it looks like it has capabilities that will help your Amazon Echo or Google Home accomplish more in relation to your mailbox or social media.

The entire system is set up based on the phrase “If this happens, then do that, which makes it nearly identical to what we practice in our logic and conditionals lessons and labs.

Log in and do some experimenting!

Hope that helps!

-A


Connect with Me GitHub Intercoastals Instagram LinkedIn Twitter