Skip to content

Instantly share code, notes, and snippets.

View elliot42's full-sized avatar

Elliot Block elliot42

  • Form Energy
  • Berkeley, CA
View GitHub Profile
From: http://nosql.mypopescu.com/post/19310504456/thoughts-about-datomic
So good.
---
Rich Hickey • a year ago
@elliot42
elliot42 / gist:5992435
Last active December 19, 2015 17:38
Shipping faster, starring duck adapters

Shipping faster with the adapter pattern

"Change is the only constant," as they say, and today we'll show you how the Adapter pattern ships change with less pain and more speed. Here's the argument:

  1. Complexity is the distance between the data structures you have, and the data structures you want.
  2. Fat models and a pile of helpers are not a reusable structure.
  3. Adapters give you purpose-built structures with abstraction and specificity.

Here's the point: you want modular, reusable tools that can be added, modified and removed with minimal disruption to the rest of the codebase. This is the thing that makes your life easier, and this is the thing that adapters give you. This article will explain how.

Value is end-to-end. Solving half the problem is not solving the problem.
(Though it may be solving a sub-problem, which may, in itself, be worth something.)
"Clojure is about programming to abstractions, among other things. So
you don't want to rely on the exact concrete types of things, but
rather the interfaces they implement." - Rich Hickey
https://groups.google.com/d/msg/clojure/NS3Cz5I9yEo/S2ekA2N_CcEJ
- Write a whole draft of what you're trying to say first, then edit.
- Not edit-as-you-go
#!/usr/bin/env ruby
#
ARGV.each do |a|
puts a
end

Four Styles of Object Organization

Object-oriented code has several common structures, and these structures repeat themselves over and over in a codebase. Each structure has pros and cons, so it's worth reviewing the tradeoffs you may be making.

Methods directly on core models

In OOP frameworks like Rails, a method's default home is the class that holds its state. Suppose that the User class has Facebook friends, Twitter followers, and LinkedIn connections. The simplest thing is:

class User
mysql> select `activity_id`,`campaign_id`,`post_id`,`action`,`controller`, count(1) from dim_pages group by `activity_id`,`campaign_id`,`post_id`,`action`,`controller` having count(1) > 1;
+-------------+-------------+---------+--------+------------+----------+
| activity_id | campaign_id | post_id | action | controller | count(1) |
+-------------+-------------+---------+--------+------------+----------+
| NULL | 1 | NULL | test | test | 9 |
| NULL | 2 | NULL | test | test | 7 |
| NULL | 3 | NULL | test | test | 7 |
| NULL | 4 | NULL | test | test | 6 |
| NULL | 5 | NULL | test | test | 6 |
| NULL | 6 | NULL | test | test | 6 |
# Euclidean distance between two n-dimensional tuples
let euclid ps qs = sqrt (sum (map (\(x,y) -> (x - y) ^ 2) (zip ps qs)))
@elliot42
elliot42 / gist:7014902
Last active December 25, 2015 17:39
Object Composition Blag

Agility and object composition

Agile teaches us that change is constant, and people commonly interpret this to mean we should work on code just enough to ship "minimum viable" hacks to the customer. This is flawed because if change is in fact constant, then our major cost is not one-time initial cost, but the ongoing cost of change. A strategy that took change really seriously would focus less on time-to-first- draft, and more on total velocity through the cycle of build-check-change-- if you knew you wanted to be able to move apartments, you would never sign up for a ten year lease, even .