Day 16 — (week 4) Promises

Eric Abell
Aug 8, 2017 · 3 min read

I’ll be honest — today could have been better.

Over the years, I have come to accept an idea that I was first introduced to in Daniel Kahneman’s book titled Thinking Fast and Slow. That idea is called Regression to the Mean. There are a lot of statistical applications for which this idea is relevant. What I’m interested in here is the idea that in the long-run, each of your days will have an “average performance.” Some days are good, some days are bad. Very few days are really good, and very few days are really bad. Of course, good and bad here are relative. But I think the idea is that if you have a really good day, then the statistical likelihood of the next day being either equally as good or better is lower compared with the likelihood that the next day will be worse. If you have an extreme day (either good or bad), chances are the next day will be more “average.”

Some people disagree strongly with this and claim that every day can be great. Perhaps so. It all depends on your perspective.

Over the weekend, our homework was to read about Promises in Javascript. I’ve dealt with Promises before. It’s a tricky concept. I can look at the code and interpret what’s being done, but it’s difficult for me to explain what’s going on or writing my own.

So it was with great anticipation that I woke this morning, knowing that I was about to go to a place where Promises would be discussed and my understanding would hopefully improve.

We began the morning with a review of the weekend’s reading. I thought that went well. There were a few questions here and there, but at this point it was just discussing the ideas and not writing any code.

First up was a roundtable discussion about some code we were given. This was tricky. It wasn’t completely clear to me from the instructions what we needed to look at. So the setup was to put a group of people together with little experience in using Promises to discuss in somewhat vague terms what was going on. Thinking back on my days teaching Calculus, I was reminded of how messy the learning process really is.

To be perfectly clear, I’m all about getting my hands dirty and figuring things out. This makes group work sometimes difficult. I really just want to spend some time on my own studying things, but instead I’m in a group of other people who are also trying to figure it out. That’s a challenging environment for me to work in productively.

It was only later, after I had some time to think, that I think I realized the point of the exercise. It wasn’t so much about implementing a Promise that performed a specific function. It was about simply writing the syntax for a Promise. My only wish was that I realized that earlier. But that’s just part of the process. Everything is easier, once you know the answer.

The pair programming activity in the morning went well. We pulled data from an API and populated a list on a webpage using XMLHttpRequest. I did this two ways. First, I used an event listener that waited until the data loaded and then populated the list. Second, I wrote a Promise to do the same thing.

After lunch, I was really hoping for a daily project that involved a deeper dive into Promises so that I could practice. The project involved pulling data from the Github API and populating a page of profile data. I suppose that I could have written a Promise to handle the GET request, but instead used fetch. Fetch does return a Promise, but I didn’t get to write the implementation details.

And as usual, the CSS styling took the longest portion of my time.

I finished the daily project and spent the rest of the afternoon going back over Promise examples, reading the homework for tomorrow, and trying to think of some different applications of Promises that would help me to understand things.

To bring it back to that idea of regression to the mean, I’d say that statistics is on my side for tomorrow being better than today. The average day is still quite high.