Skip to content

Instantly share code, notes, and snippets.

View theotherzach's full-sized avatar

Zach Briggs theotherzach

View GitHub Profile

Bottles Strategy Pattern

Challenge 1: Refactor starting from here to pattern matching/ strategy pattern so that neither Bottles nor Verse would need to be altered in order to replace verse 6 with lyrics regarding 6 packs. (Sample in the comments below. Any language of your choice as always.)

Challenge 2: Start thinking about a world where you can write 6.to_bottle. (Or however you would create a bottle number primitive in your language of choice.) I recommend against attempting to hand-crank your way there.

class Bottles
  def sing

Bottles Challenge 2

Hand Cranked Human Pattern Matching

This is not a challenge so much as a new (to me) way of looking at refactoring. As always, complete in your language of choice. First, some background:

The ruby example below maximizes simplicity at the expense of flexibility.

class Bottles

Placeholder For Bottles Solutions

  • miracle
  • solution for house
  • setup sparring stuff
  • exercism group
(define tests
'((eq? 5 (+ 2 3))
(eq? 5 (+ 3 3))))
(define (test-iter test-list results)
(cond
((null? test-list) results)
(else
(test-iter
(cdr test-list)

Group members can opt into default directions or choose to go their own way so long as it falls within the framework of the org. Framework could be "make money" or "delight customers" with base guidelines like "don't break laws".

So it's the thing we're already doing but we formalize how it actually works.

def game ->
[] >> game
def game rolls ->
def scoreIter array -> (score)
length == 0
score >> return
if [0] == 10 # sugar for >> { [0] == 10 }()
slice(1)
scoreIter((+ score 10 array[1] array[2]))
window.app = window.app || {};
(function() {
"use strict";
function truncate(div) {
var excess = div.children('ul').children('li').slice(5);
}
function verb(elements) {

Code must change. Code must tell.

Test Double has been successfully specializing in JavaScript for more than two years, which is unusual for a boutique consultancy. It was from this position that I was preparing a talk with our best practices. I was atop my favorite mountain with two brand new stone tablets, chisel in hand, ready to drop some wisdom up in here.

I hesitated. The advice I was preparing to give was advice I wasn't sure that I believed. Yes we're very good at building systems with JavaScript, but am I certain of which practices are actually beneficial vs the ones that might just be dogma?

This blog post contains the framework I used to examine our practices, for I feel that the framework is more interesting than the answers I derived.

Why Do We Code

Code serves three masters. The machine, the maintainer, and the user. I want to focus on shipping code for the user while keeping it as maintainable as possible. For the machine, it must execute, but I will ignore performan

Breakdown of Kangax JavaScript Quiz #6

Here is the original quiz. #6 asks for the output of this code:

var foo = {
  bar: function() { 
    return this.baz;
  },