Johnny Ray Austin
@recursivefunk
https://recursivefunk.io/
JSConf EU 20190602
@recursivefunk
Simple doesn't scale.
@recursivefunk
@recursivefunk
Complexity, expressed, simply.
The degree to which complexity is encapsulated.
@recursivefunk
@recursivefunk
Encapsulates a lot of complexity. Not necessarily a good thing.
@recursivefunk
Encapsulates very little complexity. Not necessarily a bad thing.
Guess the API!
@recursivefunk
exports = module.exports = createApplication;
/**
* Create an express application.
*
* @return {Function}
* @api public
*/
function createApplication() {
var app = function(req, res, next) {
app.handle(req, res, next);
};
mixin(app, EventEmitter.prototype, false);
mixin(app, proto, false);
// expose the prototype that will get set on requests
app.request = Object.create(req, {
app: { configurable: true, enumerable: true, writable: true, value: app }
})
// expose the prototype that will get set on responses
app.response = Object.create(res, {
app: { configurable: true, enumerable: true, writable: true, value: app }
})
app.init();
return app;
}
const express = require('express');
const app = express();
var m;
var events;
var existing;
checkListener(listener);
events = target._events;
if (events === undefined) {
events = target._events = Object.create(null);
target._eventsCount = 0;
} else {
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (events.newListener !== undefined) {
target.emit('newListener', type,
listener.listener ? listener.listener : listener);
// Re-assign `events` because a newListener handler could have caused
// the this._events to be assigned to a new object
events = target._events;
}
existing = events[type];
}
😅
@recursivefunk
stream.on('data', () => /* ¯\_(ツ)_/¯ */);
let propName;
// Reserved names are extracted
const props = {};
let key = null;
let ref = null;
let self = null;
let source = null;
if (config != null) {
if (hasValidRef(config)) {
ref = config.ref;
}
if (hasValidKey(config)) {
key = '' + config.key;
}
self = config.__self === undefined ? null : config.__self;
source = config.__source === undefined ? null : config.__source;
// Remaining properties are added to a new props object
for (propName in config) {
if (
hasOwnProperty.call(config, propName) &&
!RESERVED_PROPS.hasOwnProperty(propName)
) {
props[propName] = config[propName];
}
}
}
😅
@recursivefunk
const style = { style: { color: 'green' } };
const msg = 'Hello, world';
const welcome = React.createElement('h1', style, msg);
@recursivefunk
@recursivefunk
@recursivefunk
@recursivefunk
Computer emulation.
@recursivefunk
Computer resource emulation.
@recursivefunk
Application-focused.
@recursivefunk
Business logic-focused.
@recursivefunk
😳
@recursivefunk
Not the good kind.
@recursivefunk
Not the good kind.
@recursivefunk
Not the good kind?
@recursivefunk
A few considerations.
@recursivefunk
@recursivefunk
@recursivefunk
@recursivefunk
@recursivefunk
@recursivefunk
https://slides.com/johnnyray/abstractions