From 11988b15931ea47d586df0da04e711d28a9bef21 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Thu, 20 Mar 2014 12:44:57 -0400 Subject: [PATCH] fix refactoring example in guide --- archive/v0.1/getting-started.html | 8 ++++---- archive/v0.1/mithril.min.zip | Bin 19855 -> 19855 bytes 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/archive/v0.1/getting-started.html b/archive/v0.1/getting-started.html index 925a9310..b63cb2e4 100644 --- a/archive/v0.1/getting-started.html +++ b/archive/v0.1/getting-started.html @@ -362,11 +362,11 @@ this.description = function(value) {

While this decision allows better API discoverability, the trade-off is that we're largely giving up on custom constraints and behavior. For example, if we wanted to change the application to make the list be persisted, a native Array would most certainly not be a suitable class to use.

In order to deal with that type of refactoring, one can explicitly decide to support only a subset of the Array API, and implement another class with the same interface as this subset API.

Given the code above, the replacement class would only need to implement the .push() and .map() methods. By freezing APIs and swapping implementations, the developer can completely avoid touching other layers in the application while refactoring.

-
todo.Todo = Array;
+
todo.TodoList = Array;

becomes:

-
todo.Todo = {
-    push: function() { /*...*/ },
-    map: function() { /*...*/ }
+
todo.TodoList = function () {
+    this.push = function() { /*...*/ },
+    this.map = function() { /*...*/ }
 };

Hopefully these examples give you an idea of ways requirements can change over time and how Mithril's philosophy allows developers to use standard OOP techniques to refactor their codebases, rather than needing to modify large portions of the application.


diff --git a/archive/v0.1/mithril.min.zip b/archive/v0.1/mithril.min.zip index 74e7ba545514b02467a500206d2fe8a7961aa48e..632a3527d32dd5d52452986f6fc118368eda0862 100644 GIT binary patch delta 41 tcmeC5&DcMikvqVfnT3l11iChI>&P;8ZMKlTqR-ehnb+4ENP7CZ0RYx|3g7?$ delta 41 tcmeC5&DcMikvqVfnT3l11eiB+>&P-PZ?=%VqR+@Ynb+4ENP7CZ0RXq;2*dyY