Skip to content

Instantly share code, notes, and snippets.

@petsel
petsel / Die-vielen-Talente-von-JavaScript.md
Created June 5, 2014 10:10
Die-vielen-Talente-von-JavaScript.md

#Die vielen »Talente« von JavaScript

[TOC]

##Die vielen Talente von JavaScript Rollen-orientierte Programmieransätze wie Traits und Mixins verallgemeinern zu können

###TL;DR / Abriss

@petsel
petsel / custom-module-system-core.js
Created May 19, 2015 19:09
module system core ... able of being custom named/branded but also with "white label" fall-back.
(function (global, moduleSystemName, namespace) {
"use strict";
var
moduleSystem, // the "custom named" module system core.
@petsel
petsel / Object.with.without.js
Created October 5, 2015 13:30
prototypal object (de)composition methods targeting function based Traits/Mixins working from an [Object] based view as antipode to [Function.call/apply].
(function (Object, Array) {
"use strict";
var
object_prototype = Object.prototype,
isObject = function is_object (type) {
(function () {
var
global = this,
ArrProto = global.Array.prototype,
proto_slice = ArrProto.slice,
proto_map = ArrProto.map,
proto_reduce = ArrProto.reduce,
@petsel
petsel / components.Introspective_isFunction_isCallable.js
Last active December 16, 2015 05:29
Trait example for "Introspective" that implements only two methods [isFunction] and [isCallable]
/**
* see also / derived from:
* [https://github.com/petsel/composable/blob/master/src/components/Introspective/Introspective.isFunction-isCallable.js]
* [https://github.com/petsel/composable/blob/master/src/composites/Function/Function.isFunction-isCallable.js]
*/
var Introspective_isFunction_isCallable = (function () {
var
Trait, // the "Introspective_isFunction_isCallable" Trait Module.
@petsel
petsel / components.Observable_SignalsAndSlots.js
Last active December 16, 2015 05:29
Mixin example for "Observable" that implements the Signal Slot concept and provides a configurable API for [addEventListener], [removeEventListener], [hasEventListener] and [dispatchEvent]
/**
* see also / derived from:
* [https://github.com/petsel/composable/blob/master/src/components/Observable/Observable.SignalsAndSlots.js]
* [https://github.com/petsel/composable/blob/master/src/composites/Queue/QueueFactory.js]
*/
var Observable_SignalsAndSlots = (function () {
var
global = this,
@petsel
petsel / components.Enumerable_first_last.js
Last active December 16, 2015 05:29
Trait example for "Enumerable" that implements only two methods [first] and [last]
/**
* see also / derived from:
* [https://github.com/petsel/composable/blob/master/src/components/Enumerable/Enumerable.first-last-item.js]
* [https://github.com/petsel/composable/blob/master/src/composites/Array/Array.first-last.js]
*/
var Enumerable_first_last = (function () {
var
Trait, // the "Enumerable_first_last" Trait Module.
@petsel
petsel / type-composition-example_Traits-Mixin-and-Factory.js
Last active December 17, 2015 09:59
composing a Queue type from a Queue Factory component. The whole system integrates 5 composable components - an Observable Mixin, two different Allocable and three different Enumerable Traits.
var Enumerable_first_last = (function () {
var
Trait,
first = function () {
return this[0];
},
last = function () {
return this[this.length - 1];
@petsel
petsel / Function.modifiers.adviceTypes.afterThrowing-afterFinally
Last active December 17, 2015 10:08
prototypal implementations of one full set and two complementary partial sets of AOP inspired method modifiers - [Function.prototype.before], [Function.prototype.after], [Function.prototype.afterThrowing], [Function.prototype.afterFinally] and [Function.prototype.around].
/**
* see also / derived from:
* [https://github.com/petsel/composable/blob/master/src/components/Controllable/Controllable.adviceTypes.afterThrowing-afterFinally.js]
* [https://github.com/petsel/composable/blob/master/src/composites/Function/Function.modifiers.adviceTypes.afterThrowing-afterFinally.js]
*/
(function (Function) {
@petsel
petsel / __thoughts-about-how-to-adopt-principles-of-aop-to-javascripts-dynamic-and-functional-nature.md
Last active December 17, 2015 23:39
1) thoughts about how to adopt the principles of aspect oriented programming to JavaScripts dynamic and functional nature.2) point (1) now gets accompanied by a working implementation - "modification.ao.js" - of an aspect oriented system as proof of concept.3) there is a working "logging" example now too as always if one needs to justify the exi…

roughly sketched

  • runtime based only and not using any kind of JavaScript "transpilers" or JavaScript build tools for "code weaving" as in e.g. AspectJ.
  • thus being forced focusing on what ES3 language core does provide.
  • implementation of prototypal method modifiers e.g. Function.prototype.before, Function.prototype.after, Function.prototype.around as minimal set of a kind of an AOP base that already supports library / framework agnostic modification of function based control flow by just wrapping additional behaviors / advice handlers around existing methods / functions.
  • clarify role of Joinpoint, Pointcut, Advice, Aspect; especially from this point of view of what makes them distinct from existing approaches in compiled and/or non dynamic and/or non functional programming languages.