Small lessons, loosely learned

When Charlotte published her end-of-year report, she outlined her plans for 2016, which included “Document my JavaScript learning journey.”

I want to get into the habit of writing one JavaScript post every week to make sure I keep up with learning it. Even if it’s just a few words about some relevant terminology; it can be as long or short as desired or time allows, as long as it happens.

An excellent plan! If you really want to make sure you’ve understood something, write down an explanation of it. There’s nothing quite like writing to really test your grasp of an idea. Even if nobody else ever reads it, it’s still an extremely valuable exercise for yourself.

Charlotte has already started. Here’s a short post on using JavaScript to pick a random an item at random from an array:

Math.round(Math.random() * (array.length - 1))

It might seem like a small thing, but look what you have to understand:

  • How Math.round works (pretty straightforward—it rounds a floating point number to the nearest whole number).
  • How Math.random works (less straightforward—it gives a random number between zero and one, meaning you have to multiply it to do anything useful with the result).
  • How array.length works (seems straightforward—it gives you the total number of items in an array, but then catches you out when you realise there can never be an index with that total value because the indices are counted from zero …which gives rise to an entire class of programming error).

I really like this approach to learning: document each small thing as you go instead of waiting until all those individual pieces click together. That’s the approach Andy took when he was learning CSS and it led to him writing a book on the subject.

When it comes to problem-solving in general (and JavaScript in particular), I have a similar bias towards single-purpose solutions. Rather than creating a monolithic framework that attempts to solve all possible problems, I prefer a collection of smaller scripts that only do one thing, but do it really well; the UNIX philosophy.

Take, for example, Remy’s bind.js. It does two-way data-binding and nothing else. If you only need one-way data-binding, there’s Simulacra.js, which takes a similar minimalist, hands-off approach.

This approach of breaking large problems down into a collection of smaller problems also came up in a completely unrelated discussion at work recently. I floated the idea of starting a book club at Clearleft. Quite a few people are into the idea, but they’re not sure they could commit the time to reading a book on a deadline. Fair enough. Perhaps we could have the book club on a chapter-by-chapter basis? I don’t think that would work all that well for novels, but it did make me think of something related to Charlotte’s stated goal of learning more JavaScript…

Graham has been raving about the You Don’t Know JS book series by the supersmart Kyle Simpson. I suggested to Charlotte that we read through the books at the rate of one chapter a week. The first book is called Up and Going and our first chapter will be Into Programming, starting this week. Then at the end of the week we’ll get together to compare notes.

I’m hoping that by doing this together, there’s more chance that we’ll actually see it through to completion:

Why can I hit deadlines imposed by others, but not those imposed by myself?

Have you published a response to this? :

Responses

2 Likes

# Liked by Marc Drummond on Sunday, January 10th, 2016 at 5:57pm

# Liked by Front-End Front on Wednesday, January 13th, 2016 at 7:11pm

Related posts

The audience for Going Offline

A book about service workers that doesn’t assume any prior knowledge of JavaScript.

Related links

Going Offline by Jeremy Keith – a post by Marc Thiele

This is such a lovely, lovely review from Marc!

Jeremy’s way of writing certainly helps, as a specialised or technical book on a topic like Service Workers, could certainly be one, that bores you to death with dry written explanations. But Jeremy has a friendly, fresh and entertaining way of writing books. Sometimes I caught myself with a grin on my face…

Tagged with

Previously on this day

11 years ago I wrote Writing from home

Personal publishing.

12 years ago I wrote Responsive Day Out updates

A line-up change and an after-party.

13 years ago I wrote Months and years

Progressively enhancing form fields.

14 years ago I wrote Landmark roles

Extending the semantics of HTML5 documents with some accessibility hooks.

15 years ago I wrote Huffcast

Read Write Huffduff Screencast Web

18 years ago I wrote New Year’s Resolution

Liquid layouts… no, wait, come back!

19 years ago I wrote By the time I get back from Phoenix

I’m back from Arizona and my nose is firmly pressed against the grindstone here in Brighton.

22 years ago I wrote Reading on the move

Now that I’m getting ready to head off to Arizona, I’m faced with the usual dilemma of choosing the right reading material for the trip.

22 years ago I wrote Surfing Safari

It looks like I made it back just in time to witness the birth of a browser. It’s a nifty little app from Apple called Safari.

23 years ago I wrote On the road again

The packing is just about all done and I’m ready to return to the somewhat milder climes of dear old Blighty.