public
Description: A jQuery plugin for Morphic programming
Clone URL: git://github.com/nkallen/effen.git
Search Repo:
polishing readme
Nick Kallen (author)
Sun Feb 24 15:06:03 -0800 2008
commit  d79e63f1ef66264971e92bd9115ec5e17d0be672
tree    5f8847426af0034eb3cb51ee36afb1caf43c7de9
parent  eef79dc9fe89f8b8396d7ef12f6ae9a23683ca73
0
...
1
 
2
3
4
...
24
25
26
27
 
28
29
30
...
48
49
50
51
 
52
53
54
...
88
89
90
91
 
 
92
93
94
95
96
97
98
99
 
100
101
102
...
120
121
122
123
124
 
 
 
125
...
 
1
2
3
4
...
24
25
26
 
27
28
29
30
...
48
49
50
 
51
52
53
54
...
88
89
90
 
91
92
93
94
95
 
 
 
 
 
96
97
98
99
...
117
118
119
 
120
121
122
123
124
0
@@ -1,4 +1,4 @@
0
-## Effen ##
0
+# Effen #
0
 
0
 *Effen* is a jQuery plugin that supports Concrete Javascript. Concrete Javascript is a pattern in which the state and behavior of your domain are attached directly to DOM elements. This differs from MVC, where domain behavior is isolated from the view. Concrete Javascript is draws inspiration from Self's Morphic UI framework.
0
 
0
@@ -24,7 +24,7 @@ That's all there is to it. But there are some subtle details to bear in mind:
0
     $('div').fn({ foo: function() {} });
0
     $('div.special').fn({ foo: function() {} });
0
     
0
-The latter takes precedence because it appears last--NOT because the selector is more specific. This may be changed in future releases.
0
+ The latter takes precedence because it appears last--NOT because the selector is more specific. This may be changed in future releases.
0
 
0
 ## An in-depth example of Concrete Programming ##
0
 
0
@@ -48,7 +48,7 @@ Suppose we have the following HTML code, representing a Script that has many Sce
0
       </ol>
0
     </div>
0
 
0
-### Let's start with some simple CRUD operations. To "create" a scene, we POST to the url: ###
0
+### Let's start with some simple CRUD operations. To *create* a scene, we POST to the url: ###
0
 
0
     $('.scenes').fn({
0
       create: function() {
0
@@ -88,15 +88,12 @@ We'd also like to bind the &lt;Backspace&gt; key from within the Dialog characte
0
           $.delete($(this).attr('url'), $(this).remove);
0
       },
0
       isBlank: function() {
0
- return $(this).fn('character').fn('isBlank') && $(this).fn('text').fn('isBlank');
0
+ return $(this).find('input[@name=character]').val() == "" &&
0
+ $(this).find('input[@name=text]').val() == "";
0
       },
0
     });
0
     
0
-Using the technique shown in the previous section, the character input is given a reference to the dialog, and the dialog a reference to the character and text (omitted here). `isBlank` is defined on character and text thusly:
0
-
0
- $('*:input').fn({
0
- isBlank: function() { return $(this).val() == '' }
0
- });
0
+Using the technique shown in the previous section, the character input is given a reference to the dialog (omitted here).
0
 
0
 ### Polymorphism in Concrete Javascript ###
0
 
0
@@ -120,4 +117,6 @@ At this point, we may notice that the definition of delete is the same for Scene
0
         if ($(this).fn('isBlank'))
0
           $.delete($(this).attr('url'), $(this).remove);
0
       }
0
- });
0
\ No newline at end of file
0
+ });
0
+
0
+So now we have achieved a kind of polymorphism: Both Scenes and Dialogs respond to `isBlank`, though each have differing implementations. Each has a different `url` attribute and each (given that they are DOM objects) can be `removed`. Given that they conform to the same interface, we can implement a generic `delete` method for both of them.
0
\ No newline at end of file

Comments

    No one has commented yet.