My Semi-Public Tracking of PreCourse Completion

Section 1:

  1. Slides: Start Coding in JavaScript: Should take 1-4 hours (done)
  2. Beginner’s Guide to HTML/CSS: Should take 1-2 hours (done)
  3. Eloquent JavaScript, Chapters 1-4: Expected 4-6 hours (done)
  4. Eloquent JavaScript, Chapters 5-21: Not Required but an excellent place to do extra work. (remains to do)
Section 1 Checklist:
  • Have basic HTML knowledge including html, head, script, body, div, a, and p
    (done)
  • Have basic CSS knowledge including CSS rules, selectors, and, basic styling
    (done)
  • Have a basic knowledge of JavaScript, including (all done)
    • firm grasp of JavaScript syntax, and fundamental programming concepts
    • basic  data types: Objects, arrays, numbers, strings boolean, null and undefined.
    • Control flow: for and for…in loops, while, if, and else

SECTION 2: Our development Workflow

  1. Slides: Illustrated Git (should take 30 minutes)
  2. How to Use the Terminal: The Basics (should take 15 minutes)
  3. Git Immersion: Labs 1-30 (should take 3 hours)
  4. Git Immersion: Labs 31-53 Not Required but an excellent place to do extra work.
  5. GitHub – Forks and Pull Requests: (10 minutes)
  6. HR Git Workflow (10 minutes)
SECTION 2 CHECKLIST:
  • Know how to open Terminal and be comfortable using the following commands:  cd, ls, mv, cp, and rm.  (Pre-existing. I would have included “pipe” and more if I was making the list.) (done)
  • Know what a version control system is and why you’d want to use it. (done)
  • Know basic git commands including: clone, push, pull, add, status, diff, commit, and remote (done)
  • Know what a pull request is. (done)
  • Know what a fork is (done)
  • Know how to submit your pre-course work to HR instructors for evaluation. (done)

SECTION 3: Introduction to Automated Testing

  1. Testing Your JavaScript Using Mocha: 60 minutes
  2. JavaScript Koans: 2 hours (note: this expectation differs from previous cohort by asking to complete ALL koans, not just first 5)
SECTION 3 CHECKLIST:
  • Be comfortable with basic testing syntax such as  describe, it, expect, eq1, and equal. (done)
  • Understand the purpose of an expectation or assertion, and what it means for a test to fail.(done)
  • Feel comfortable with being given a failing test and making it pass. (done)
  • Added: Be comfortable using Chrome Dev Tools to research failing tests.
    (still not totally comfortable)
  • Added: Develop habit of noting what misconception in understanding led to a failing test.  Ask the question “What leads me to believe this result will occur?”
    (done)

SECTION 4: Advanced javascript, Part 1

  1. Discover DevTools, Chapters 1-5 (2 hours)
  2. Debugging JavaScript (30 minutes
  3. Underbar, Part 1: _.identity() through _.reduce() (9 hours)
SECTION 4 CHECKLIST:
  • Start using the Chrome Developer Tools to debug your JS code.
    (still not totally comfortable)

    • Be familiar with the following tools and use them to debug code: debugger (statements and breakpoints).  Watch expressions
  • Check code and make sure I am re-using functions whenever possible.
    (still not totally comfortable)
  • Have a solid understanding of the following functions and what they do:
    • _.each()
    • _.indexOf()
    • _.map()  
    • _.reduce()  
    • _.filter()  
    • _.reject()
  • Be familiar with the other Underbar functions we’ve implemented. (done)
  • Added: After completing this assignment, compare my code to published implementation of Underscore. (done)
  • Added: Explore implementing as many functions as possible using recursion. (done)
  • Added: On a daily basis, reimplement at least 5 randomly selected underbar functions, without stubs, hints, or test suite.(doing)

SECTION 5: Advanced Javascript, Part II

  1. HR106: Scopes (30 min)
  2. HR107: Executions Contexts (30 min)
  3. HR108: Contexts vs Objects (30 min)
  4. HR109: Closures (30 min)
  5. Underbar, Part II _contains() through _.shuffle() (12 hours)
SECTION 5 CHECKLIST:
  • Have a solid understanding of the following functions, what they do and how they are implemented: (done)
    • _.extend()
    • _.defaults()
    • _.once()
    • _.memoize()
    • _.delay()
  • Be familiar with the rest of the Underbar functions. (done)
  • Have a basic understanding of closures, lexical scope and know what it means for a variable to be “in scope” (done)
  • Be familiar with what .call and .apply do, including understanding their syntax. (done)
  • Added: Understand “this” keyword. (done)
  • Added: After completing this assignment, compare my code to published implementation of Underscore. (done)
  • Added: Explore implementing as many functions as possible using recursion. (done)
  • Added: On a daily basis, reimplement at least 5 randomly selected underbar functions, without stubs, hints, or test suite. (doing)
  • Added: Complete as many “extra credit” underbar functions as possible. (doing)

SECTION 6: front-end development

  1. CSS Cross-Country, Parts 1-4 (4 hours) (done through part 7.  Should review.)
  2. Try jQuery (2 hours) (done but should redo.)
  3. Twittler (should take 6 hours) (done, but continue to update as things sink in from jQuery or CSS)
SECTION 6 CHECKLIST:
  • Understand how to dynamically generate HTML and append it to a page using jQuery (done)
  • Understand what evants are and how to attach them to a DOM/jQuery element (done)
  • Do NOT over emphasize CSS too much.  It is totally ok to depend on lookup. (that is good….)

SECTION 7: INTRODUCTION TO computer science

  1. The Keyword this
  2. HR116 Decorators
  3. HR117 Functional Classes
  4. HR118 Prototype Chains
  5. Prototypal Class
  6. Pseudoclassical Class
  7. Recursion in JavaScript (2 hours)
  8. Recursion Assignment (8 hours)
  9. Added:  There are multiple opportunities for extra credit in Recursion. At least attempt them
SECTION 7 CHECKLIST:
  • Understand what recursion is, in general (done)
  • Understand base cases, and what it means for recursion to terminate (done)
  • Spend some time thinking about what sort of problems recursion might be a good fit for. (done)
  • Added: write a blog post regarding calculating the probabilities in a game of risk.  Refactor afterward using memoize to demonstrate time savings. (remains to be done, and I need to figure out how to make memoize work with multiple inputs.)

Advertisements
My Semi-Public Tracking of PreCourse Completion

Sum of Natural Numbers.

What’s the sum of the Natural Numbers?

Recently the internet was abuzz with the claim that the sum of all positive integers is -112.

Clearly, a suprising result — but you can look at the video which went viral here.

Now the most unsupportable step they take in their presentation is when they claim that the series

1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 + 1 ... = 12.

as it “bounces back and forth between 1 and 0”.  I thought I’d NOT use that step and see what result we get.

S = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + ....
3S =      + 3         + 6         + 9           + 12           + 15 + ....

thus

-2S =(1 + 2) + (4 + 5)  +  (7 + 8)  +  (10 + 11)  +   (13 + 14)  + ....
-2S = (3)    +    (9)    +    (15)   +    (21)    +     (27)  + ....

so

-23 S = 1 +     3 +    5 +    7 +    9 +    .....

but   2S  =     2 +    4 +    6  +    8 +    ……

so   43S = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + ….

But wait, that’s what S was, right?

So    43S = S  →  13S = 0  → S = 0

See, I told you they were wrong….

(I hope it’s obvious that the work I present here has serious flaws. If you’d like a formal explanation of what those are, send me a mail and I’ll share the secrets.)

Sum of Natural Numbers.

Hey, Loosen Up a Little

So I’ve known for a while that I can be a tad obsessive — here’s an example. A long time ago someone in my family gave me a T-shirt with the logo “For a good Prime, call 555-2357!”

I’m sure I smiled and thanked them for thinking of me, the official “math nerd” in their life, but here’s the thing: I checked. Of course I checked, after all, why else would one own Mathematica on their home computer?

In[1]:= PrimeQ[5552357]

Out[1]= False

In[2]:= FactorInteger[5552357]

Out[2]= {{67, 1}, {79, 1}, {1049, 1}}

How embarrassing for the T-shirt maker, right? Or maybe it’s an inside joke? Maybe the goal was to get non-math people to get the math people to wear a shirt that other math nerds will make fun of? In any event, the shirt got shoved in the back of the drawer never to be worn.

Fast forward to this morning. When I was down in Wilmington last week my wife reorganized part of our house, including my dresser, an neatly reorganized my t-shirts. This made me realize just how many t-shirts I have so I started going through them with an eye towards culling the herd.

What to do with this particular shirt? I’m leaning towards donating it to Goodwill with an errata statement stapled to the collar.

Hey, Loosen Up a Little

Picking up HTML/CSS in a couple of hours

One of my recent concerns as I progress through the Hackreactor “pre-course” curriculum is their seeming assumption that all of their students are fully conversant with respect to all aspects of both HTML and CSS. Or if not, that one can pick up everything that’s important about both in the span of a couple of hours.

Given there are folks out there who make a pretty good living just coding static webpages with HTML, I figured that this is probably not exactly true, but I soldiered on and have pored over both for the last several days. Our project is to make a rough mimicry of “Twitter” mostly using jQuery.  As I figured (I think correctly) that one can’t really understand jQuery unless you understand the HTML/CSS code you’re trying to get created, I decided to spend today just creating an example static webpage that I’m trying to get jQuery to create dynamically. Now, I can’t show code because it’s a proprietary curriculum, but here’s a screenshot:
Screen Shot

So, what have I learned today?  Well first, while it does take only a handful of hours to buzz through the http://www.codeacademy.com introduction to HTML/CSS, if you are the sort that wants to “tweak” your webpage, there is a MASSIVE number of nuances to master. I’ve had a great deal of fun messing around but what I’ve REALLY learned is that I have a lot more to learn.  Secondly, and far more importantly, designing a webpage intentionally to be dynamic takes a great deal more thought.  Already as I look at my code I’m realizing that most of it will have to be ripped out and redone.  Today wasn’t wasted, but I feel like I just climbed a foothill to get ready to climb a small mountain tomorrow.

Picking up HTML/CSS in a couple of hours

Mr Holland’s Opus

My favorite movie about teaching is most definitely Mr Holland’s Opus, in fact, I think it’s really the only movie which truly captures the real struggles of day-to-day life as a teacher:  trying to reach the reluctant student, how their “actual lives” quite often trump the “school lives”, how teachers inevitably have to struggle to make ends meet financially, how they’ll often short change the relationships with their own children for the sake of their students. I’ve always appreciated the grittiness, the reality of the movie — especially how teachers support and encourage each other throughout the film.

I love everything about the film – except the ending.  There’s a story, perhaps apocryphal, that the original ending of the film was as honest as the rest of the movie — that after a long career of service, Mr. Holland’s school eliminated the music program and he was quietly retired.  But that as they looked at the daily rushes, it was just too depressing.  So they fabricated an ending where the Governor (an ex-student of his) secretly rounded up hundreds of his old charges, that they all miraculously still played their instruments, and came together to play his “Opus”.  To be sure, it’s a feel good moment, but it’s the one big thing about the movie which simply doesn’t ring true.

So let me tell you how my “last moments” are going to end this afternoon.  I’m scheduled to oversee a help session – one that I expect almost no-one to attend.  Except for one young lady who STILL has an incomplete from the first trimester (ended before Thanksgiving) because she still needs to take the chapter 3 test.  Given I told her two weeks ago that today is the absolutely, positively last opportunity to take that test, of course, this afternoon is when she’s planning to take it.  As she was leaving class this morning, I reminded her of the appointment.

I’ll be there.”, she said cheerfully, “Oh, and what chapter is it again?”

That, ladies and gentlemen, is how a career in teaching really ends.  I won’t want it any other way.

Mr Holland’s Opus

Remembering to say “yet”

As a teacher, I had one major pet peeve.  Inevitably you’ll have students who, after the class has reviewed a difficult assignment (perhaps for the 3rd time) just after you’ve asked to make sure everyone is ready to move on to a new topic, there will be a student who will plaintively say

” I don’t GET it.”

“OK, so what are we still stuck on, where did you get lost?”

“I just don’t get ANY of it” — said in a tone of  voice that implies their state of confusion and frustration was central to how they define themselves.

It is in those situations that I usually reminded them of rule number one for all of my classes, students are free to voice any such frustrations, go ahead and share their lamentations with full orchestration, as long as they add one important word:  YET.

Adding that one world to the sentence flips the entire meaning of the sentence:  now it’s “I’m hugely frustrated, currently, but I have not given up.  I expect I will at some point achieve a breakthrough.”  If for no other reason, adding “yet” to the end of such sentences serves to diminish the tension which inevitably seems to be part and parcel of significant learning.  In the 27 years I taught math, my favorite moment was when a student came late to school and walked into the room halfway through the lecture presenting the fundamental theorem of calculus.

“What the hell is THAT?”  (very long embarrassed silence)    “…yet?”

So here I am half way though the pre-course curriculum, fighting my way to learn a mountain of background material:  HTML and CSS so that I can understand the JQUERY lessons, so that I can begin to work on the Twiddler assignment and have it completed by the hard deadline on Monday.  Which is the soft deadline for the recursion assignment.  And the date of our first (real) self assessment.

Suddenly I have WAY more empathy for my students’ who just had to give voice their frustrations.  But having said that, “YET” is still my favorite word.

Remembering to say “yet”

Grrrrr

I’m gonna warn folks that this posting will be heavy on the geek side of things but I thought I’d share a little story from my “Precourse” HR assignment.  One part of this has been a challenge to rewrite methods AKA functions which are part of the widely used _.underbar toolkit.

In our instructions for “_.memoize” we were told the following instructions

// Memorize an expensive function's results by storing them. 
// You may assume that the function takes only one argument 
// and that it is a primitive.
// memoize could be renamed to oncePerUniqueArgumentList; 
// memoize does the same thing as once, but based on many 
// sets of unique arguments.
// _.memoize should return a function that, when called, 
// will check if it has already computed the result for the 
// given argument and return that value instead if possible.

So I was actually pretty proud of myself when I came up with the following.

_.memoize = function(func) {
    var prevResults = {}; 
    return function(x){
       if(prevResults[x]===undefined){
           prevResults[x]=func(x);
       }
       return prevResults[x];
    };
 };

The function work, I tested it on fibonnacci which is the “go to” standard in functions which slow to a start with repeated unnecessary function calls, so it was with a sense of certainty that I delivered it for grading. Fail.

Ponder ponder ponder.  Read read read.  One student said “you have to use .apply” – but I’m still peeved because I know my method already works, at least for me.  As a last resort, I picked apart the test that the grading program was using – lo and behold – they were using a function with two parameters – not one as promised.  Grrrr.

But, as later explained, ALL functions in Javascript have precisely ONE input object and that OBJECT can contain a whole suite of variables that will be used as inputs.  I’m till ticked off that they said there will be exactly one parameter for the function and that will be a primitive.  I’m pretty sure that the argument object to a function is not a primitive but here’s the thing, I doubt I will soon forget any of this.  Dr Eleanor Duckworth proved to be right (yet) again.

For the geeks that are still with me, this is how you do it correctly.

 _.memoize = function(func) {
     var prevResults = {};
     return function(x){
        if(prevResults[x]===undefined){
           prevResults[x]=func.apply(null,arguments);
        }
        return prevResults[x];
     };
 };

UPDATE (March 6th)

I thought I was frustrated before, now I’m off the charts.   Bear with me.

1) Saying we can “assume” there is only one parameter makes it extremely easy to
set up an object with stored, previously computed results – a la my first example.

2) So, ok, it makes sense to give an example in the test that is a multivariable
function, making students understand that in JavaScript all functions get ONE
input, the arguments array.

BUT

3) The code above, that I’ve been proud of for several weeks is horribly broken.

var addem = function(a, b){
  return a + b;
};
memoize = function(func) {
  var preResults = {};
  return function(x){
    if (preResults[x] === undefined){
       preResults[x] = func.apply(null,arguments);
    }
    console.log(preResults);
    return preResults[x];
  };
};
 
var storedAddem = memoize(addem);
storedAddem(1, 3); // preResults is { '1': 4 }
                   // returns 4
storedAddem(1, 5); // preResults is { '1': 4 }
                   // returns 4

GULP??  My memoize function helped me make sure that 1 + anything is now 4.

Yet all tests happily pass.  Makes me wonder how much of the rest of my understanding is likewise fragile.

Grrrrr