Browse Source

Update patterns for getters

Steven Silvester 8 years ago
parent
commit
745a3addc0
1 changed files with 8 additions and 0 deletions
  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`