Last active
December 3, 2015 21:40
-
-
Save lazywithclass/fae39321cfe9ec64004a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// review programming-itro-1.js | |
// questions? | |
// no OOP, FP | |
// model a car | |
// break it up in units <-- ! | |
// model a tyre | |
function spin(wheel) { | |
wheel.isSpinning = true; | |
return wheel; | |
} | |
function isFlat(wheel) { | |
return wheel.flat; | |
} | |
function inflate(wheel) { | |
wheel.flat = false; | |
return wheel; | |
} | |
// model an engine | |
function start(engine) { | |
engine.on = true; | |
return engine; | |
} | |
function stop(engine) { | |
engine.on = false; | |
return engine; | |
} | |
function isStarted(engine) { | |
return engine.on; | |
} | |
function wearOff(engine) { | |
engine.statusIndex = engine.statusIndex + 1; | |
return engine; | |
} | |
// model the steering wheel | |
function steer(steeringWheel, direction) {} | |
// put it all together in the car | |
// start the car | |
function start(car) {} | |
// query your modelled objects to understand the state of the whole thing | |
// come up with some function you might think would be useful |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment