A place to cache linked articles (think custom and personal wayback machine)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 年之前
12345678910111213141516171819202122232425262728293031323334353637383940
  1. title: Small lessons, loosely learned
  2. url: https://adactio.com/journal/10078
  3. hash_url: 5ca3d2195e5b23f6dca45fcab9327040
  4. <p>When <a href="https://www.lottejackson.com/learning/what-a-year-what-next">Charlotte published her end-of-year report</a>, she outlined her plans for 2016, which included “Document my JavaScript learning journey.”</p>
  5. <blockquote>
  6. <p>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.</p>
  7. </blockquote>
  8. <p>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.</p>
  9. <p>Charlotte has already started. Here’s <a href="https://www.lottejackson.com/learning/javascript-learning-1">a short post on using JavaScript to pick a random an item at random from an array</a>:</p>
  10. <pre><code>Math.round(Math.random() * (array.length - 1))
  11. </code></pre>
  12. <p>It might seem like a small thing, but look what you have to understand:</p>
  13. <ul>
  14. <li>How <code>Math.round</code> works (pretty straightforward—it rounds a floating point number to the nearest whole number).</li>
  15. <li>How <code>Math.random</code> 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).</li>
  16. <li>How <code>array.length</code> 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 <a href="https://en.wikipedia.org/wiki/Off-by-one_error">an entire class of programming error</a>).</li>
  17. </ul>
  18. <p>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 <a href="http://www.andybudd.com/archives/2003/08/clearing_floats/">Andy took when he was learning CSS</a> and it led to him <a href="https://openlibrary.org/books/OL25151975M/CSS_mastery">writing a book on the subject</a>.</p>
  19. <p>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; <a href="https://en.wikipedia.org/wiki/Unix_philosophy">the UNIX philosophy</a>.</p>
  20. <p>Take, for example, <a href="https://remysharp.com/2015/06/02/bind">Remy’s bind.js</a>. It does two-way data-binding and nothing else. If you only need one-way data-binding, there’s <a href="http://simulacra.js.org/">Simulacra.js</a>, which takes a similar minimalist, hands-off approach.</p>
  21. <p>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 <a href="http://clearleft.com/">Clearleft</a>. 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…</p>
  22. <p><a href="https://gablaxian.com/">Graham</a> has been raving about the <a href="https://github.com/getify/You-Dont-Know-JS/blob/master/README.md#you-dont-know-js-book-series"><cite>You Don’t Know JS</cite></a> book series by the supersmart <a href="http://getify.me/">Kyle Simpson</a>. I suggested to Charlotte that we read through the books at the rate of one chapter a week. The first book is called <a href="https://github.com/getify/You-Dont-Know-JS/blob/master/up%20%26%20going/README.md"><cite>Up and Going</cite></a> and our first chapter will be <a href="https://github.com/getify/You-Dont-Know-JS/blob/master/up%20&amp;%20going/ch1.md"><cite>Into Programming</cite></a>, starting this week. Then at the end of the week we’ll get together to compare notes.</p>
  23. <p>I’m hoping that by doing this together, <a href="http://ianfeather.co.uk/communal-momentum-and-accountability/">there’s more chance that we’ll actually see it through to completion</a>:</p>
  24. <blockquote>
  25. <p>Why can I hit deadlines imposed by others, but not those imposed by myself?</p>
  26. </blockquote>