Skip to content

Instantly share code, notes, and snippets.

@JordanRickman
JordanRickman / sketch_apr01a.ino
Created April 2, 2019 01:48
ATTiny Sketch for Homemade Hardware
const float FACTOR = 1.05946; // One semitone
float freq = 440;
const int BUTTON_UP = 3;
const int BUTTON_DOWN = 4;
const int SPEAKER = 0;
bool up_pressed = false;
bool down_pressed = false;
@JordanRickman
JordanRickman / index.html
Last active March 7, 2019 23:44
Sound in Space: Mono Assignment
<html>
<head>
<script src="https://unpkg.com/tone@13.4.9/build/Tone.js"></script>
<script src="sketch.js"></script>
</head>
<body>
<button id="playbutton">
Play
</button>
</body>
@JordanRickman
JordanRickman / ConnectorPattern.md
Last active April 17, 2023 01:35
The Connector OOP Pattern

Connectors: A Design Pattern for Maintaining Consistent Object Relationships

The entities in an application's domain model are defined in large part by their relationships between them. The basic three are one-to-one, one-to-many, and many-to-many, but additional invariants may be layered on top of these. In a traditional OOP style, entities are responsible for maintaining these invariants, via logic in their public mutator methods. I propose an alternative that I call the connector pattern. In the connector pattern, object relationships are created and destroyed (connected and disconnected) by a third object called a Connector.

Why Connectors?

While objects should be responsible for maintaining their own local invariants, relationships are not local. They encompass both objects involved in a relationship. As a result, mutator methods on both objects must enforce a shared invariant. If a Foo has many Bars, then Foo.addBar(Bar) and Bar.setFoo(Foo) should be equivalent operations. These two meth

@JordanRickman
JordanRickman / bound-privileged-method.js.md
Last active March 3, 2017 04:51
Bound Privileged Method Pattern

JavaScript Pattern: The Bound Privileged Method

Information Hiding in JavaScript

In JavaScript, we can exploit closure to create private variables. Like so:

function Constructor() {
  var count = 0;
  this.getCount = function() { return count; };
 this.increment = function() { count++; };