diff --git a/JavaScript/actor-closure.js b/JavaScript/actor-closure.js index 5ee6cd8..6710af0 100644 --- a/JavaScript/actor-closure.js +++ b/JavaScript/actor-closure.js @@ -33,9 +33,9 @@ class Point { this.y = y; } - move(x, y) { - this.x += x; - this.y += y; + move(dx, dy) { + this.x += dx; + this.y += dy; } clone() { diff --git a/JavaScript/actor-compose.js b/JavaScript/actor-compose.js index 01b9ca4..3662ef5 100644 --- a/JavaScript/actor-compose.js +++ b/JavaScript/actor-compose.js @@ -36,9 +36,9 @@ class Point { this.y = y; } - move(x, y) { - this.x += x; - this.y += y; + move(dx, dy) { + this.x += dx; + this.y += dy; } clone() { diff --git a/JavaScript/actor-inheritance.js b/JavaScript/actor-inheritance.js index 2bacedc..56325cb 100644 --- a/JavaScript/actor-inheritance.js +++ b/JavaScript/actor-inheritance.js @@ -35,9 +35,9 @@ class Point extends Actor { this.#y = y; } - move(x, y) { - this.#x += x; - this.#y += y; + move(dx, dy) { + this.#x += dx; + this.#y += dy; } clone() { diff --git a/JavaScript/actor.js b/JavaScript/actor.js index b611ef2..925e75a 100644 --- a/JavaScript/actor.js +++ b/JavaScript/actor.js @@ -11,9 +11,9 @@ class Point { this.#y = y; } - #move(x, y) { - this.#x += x; - this.#y += y; + #move(dx, dy) { + this.#x += dx; + this.#y += dy; } #clone() { @@ -35,8 +35,8 @@ class Point { if (this.#processing) return; this.#processing = true; while (this.#queue.length) { - const { method, x, y, resolve } = this.#queue.shift(); - if (method === 'move') resolve(this.#move(x, y)); + const { method, x: dx, y: dy, resolve } = this.#queue.shift(); + if (method === 'move') resolve(this.#move(dx, dy)); if (method === 'clone') resolve(this.#clone()); if (method === 'toString') resolve(this.#toString()); } diff --git a/JavaScript/aspect.js b/JavaScript/aspect.js index 62a0597..ab74a5f 100644 --- a/JavaScript/aspect.js +++ b/JavaScript/aspect.js @@ -9,9 +9,9 @@ class Point { this.#y = y; } - move(x, y) { - this.#x += x; - this.#y += y; + move(dx, dy) { + this.#x += dx; + this.#y += dy; } clone() { @@ -34,8 +34,8 @@ const aspect = (target, methodName, { before, after }) => { }; aspect(Point.prototype, 'move', { - before(x, y) { - console.log(`Before move: ${this.toString()} moving by (${x},${y})`); + before(dx, dy) { + console.log(`Before move: ${this.toString()} moving by (${dx},${dy})`); }, after() { console.log(`After move: ${this.toString()}`); diff --git a/JavaScript/closure-class.js b/JavaScript/closure-class.js index 530c36c..d67de58 100644 --- a/JavaScript/closure-class.js +++ b/JavaScript/closure-class.js @@ -1,17 +1,16 @@ 'use strict'; class Point { - constructor(ax, ay) { - this.x = ax; - this.y = ay; + constructor(x, y) { + this.x = x; + this.y = y; + const move = (dx, dy) => { + this.x += dx; + this.y += dy; + }; const clone = () => new Point(this.x, this.y); const toString = () => `(${this.x}, ${this.y})`; - return { clone, toString }; - } - - move(dx, dy) { - this.x += dx; - this.y += dy; + return { move, clone, toString }; } } diff --git a/JavaScript/event-aggregation.js b/JavaScript/event-aggregation.js index ce9c63b..ef404d3 100644 --- a/JavaScript/event-aggregation.js +++ b/JavaScript/event-aggregation.js @@ -10,9 +10,9 @@ class Point { this.#x = x; this.#y = y; - emitter.on('move', ({ x, y }) => { - this.#x += x; - this.#y += y; + emitter.on('move', ({ x: dx, y: dy }) => { + this.#x += dx; + this.#y += dy; }); emitter.on('clone', (callback) => { diff --git a/JavaScript/event-class.js b/JavaScript/event-class.js index e3d1c82..665bad9 100644 --- a/JavaScript/event-class.js +++ b/JavaScript/event-class.js @@ -9,9 +9,9 @@ class Point { this.#x = x; this.#y = y; this.#events = { - move: ({ x, y }) => { - this.#x += x; - this.#y += y; + move: ({ x: dx, y: dy }) => { + this.#x += dx; + this.#y += dy; }, clone: () => new Point({ x: this.#x, y: this.#y }), toString: () => `(${this.#x}, ${this.#y})`, diff --git a/JavaScript/event-compose.js b/JavaScript/event-compose.js index 2b9ccbf..0c08cdd 100644 --- a/JavaScript/event-compose.js +++ b/JavaScript/event-compose.js @@ -11,9 +11,9 @@ class Point { this.#y = y; this.emitter = new EventEmitter(); - this.emitter.on('move', ({ x, y }) => { - this.#x += x; - this.#y += y; + this.emitter.on('move', ({ x: dx, y: dy }) => { + this.#x += dx; + this.#y += dy; }); this.emitter.on('clone', (callback) => { diff --git a/JavaScript/memory-class.js b/JavaScript/memory-class.js index 73eb942..bfeeb5f 100644 --- a/JavaScript/memory-class.js +++ b/JavaScript/memory-class.js @@ -14,9 +14,9 @@ class Point { } } - move(x, y) { - Atomics.add(this.view, 0, x); - Atomics.add(this.view, 1, y); + move(dx, dy) { + Atomics.add(this.view, 0, dx); + Atomics.add(this.view, 1, dy); } clone() { diff --git a/JavaScript/oop-private.js b/JavaScript/oop-private.js index dcf8ee1..3c951cc 100644 --- a/JavaScript/oop-private.js +++ b/JavaScript/oop-private.js @@ -9,9 +9,9 @@ class Point { this.#y = y; } - move(x, y) { - this.#x += x; - this.#y += y; + move(dx, dy) { + this.#x += dx; + this.#y += dy; } clone() { diff --git a/JavaScript/oop-public.js b/JavaScript/oop-public.js index ea66ced..01b92dd 100644 --- a/JavaScript/oop-public.js +++ b/JavaScript/oop-public.js @@ -6,9 +6,9 @@ class Point { this.y = y; } - move(x, y) { - this.x += x; - this.y += y; + move(dx, dy) { + this.x += dx; + this.y += dy; } clone() { diff --git a/JavaScript/oop-static.js b/JavaScript/oop-static.js index 0e48e6e..95f67f6 100644 --- a/JavaScript/oop-static.js +++ b/JavaScript/oop-static.js @@ -6,9 +6,9 @@ class Point { this.y = y; } - static move(point, x, y) { - point.x += x; - point.y += y; + static move(point, dx, dy) { + point.x += dx; + point.y += dy; } static clone({ x, y }) { diff --git a/JavaScript/procedural.js b/JavaScript/procedural.js index 5824903..57bc7ef 100644 --- a/JavaScript/procedural.js +++ b/JavaScript/procedural.js @@ -10,9 +10,9 @@ const clone = (point) => { return createPoint(x, y); }; -const move = (point, x, y) => { - point.x += x; - point.y += y; +const move = (point, dx, dy) => { + point.x += dx; + point.y += dy; }; const toString = (point) => { diff --git a/JavaScript/prototype-assign.js b/JavaScript/prototype-assign.js index b4b854a..8ceb1c2 100644 --- a/JavaScript/prototype-assign.js +++ b/JavaScript/prototype-assign.js @@ -4,9 +4,9 @@ const clone = function () { return new Point(this.x, this.y); }; -const move = function (x, y) { - this.x += x; - this.y += y; +const move = function (dx, dy) { + this.x += dx; + this.y += dy; }; const toString = function () { diff --git a/JavaScript/prototype-new.js b/JavaScript/prototype-new.js index 99a2f23..a194b2d 100644 --- a/JavaScript/prototype-new.js +++ b/JavaScript/prototype-new.js @@ -13,9 +13,9 @@ proto.clone = function () { return new Point(this.x, this.y); }; -proto.move = function (x, y) { - this.x += x; - this.y += y; +proto.move = function (dx, dy) { + this.x += dx; + this.y += dy; }; proto.toString = function () { diff --git a/JavaScript/prototype-null.js b/JavaScript/prototype-null.js index d4ae406..b5e4c0f 100644 --- a/JavaScript/prototype-null.js +++ b/JavaScript/prototype-null.js @@ -11,9 +11,9 @@ Point.prototype.clone = function () { return new Point(this.x, this.y); }; -Point.prototype.move = function (x, y) { - this.x += x; - this.y += y; +Point.prototype.move = function (dx, dy) { + this.x += dx; + this.y += dy; }; Point.prototype.toString = function () { diff --git a/JavaScript/prototype-self.js b/JavaScript/prototype-self.js index f0adf23..a10816d 100644 --- a/JavaScript/prototype-self.js +++ b/JavaScript/prototype-self.js @@ -13,9 +13,9 @@ proto.clone = function () { return createPoint(this.x, this.y); }; -proto.move = function (x, y) { - this.x += x; - this.y += y; +proto.move = function (dx, dy) { + this.x += dx; + this.y += dy; }; proto.toString = function () { diff --git a/JavaScript/prototype.js b/JavaScript/prototype.js index cdcb879..f815958 100644 --- a/JavaScript/prototype.js +++ b/JavaScript/prototype.js @@ -9,9 +9,9 @@ Point.prototype.clone = function () { return new Point(this.x, this.y); }; -Point.prototype.move = function (x, y) { - this.x += x; - this.y += y; +Point.prototype.move = function (dx, dy) { + this.x += dx; + this.y += dy; }; Point.prototype.toString = function () {