Преглед на файлове

Merge pull request #1252 from blink1073/getter-pattern

Update patterns docs for getters
Afshin Darian преди 8 години
родител
ревизия
89ef84db41
променени са 1 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 8 0
      tutorial/patterns.md

+ 8 - 0
tutorial/patterns.md

@@ -93,6 +93,13 @@ The subclassed methods would be called before the subclass constructor has
 finished evaluating, resulting in undefined state.
 
 
+## Getters vs. Methods
+
+Prefer a method when the return value must be computed each time.
+Prefer a getter for simple attribute lookup.
+A getter should yield the same value every time.
+
+
 ## Data Structures
 
 Prefer to use Phosphor [Phosphor `Vector`](http://phosphorjs.github.io/phosphor/api/classes/_collections_vector_.vector.html) 
@@ -118,6 +125,7 @@ Prefer an `ISequence` when:
 - A return value or public attribute based on an internal `Vector` where the 
 value may need to be accessed randomly.
 
+
 ## DOM Events
 
 If an object instance should respond to DOM events, create a `handleEvent`