[sledge] Cleanup: rename class, remove code, add comments.

TEST=dart_sledge_tests

Change-Id: I2c5f1104fe361be3ae8a28b79b61431ff77c8a5d
diff --git a/public/dart/sledge/BUILD.gn b/public/dart/sledge/BUILD.gn
index 641e243..22d3118 100644
--- a/public/dart/sledge/BUILD.gn
+++ b/public/dart/sledge/BUILD.gn
@@ -14,8 +14,8 @@
     "src/document/document.dart",
     "src/document/document_id.dart",
     "src/document/leaf_value.dart",
+    "src/document/node_value.dart",
     "src/document/value.dart",
-    "src/document/value_node.dart",
     "src/document/value_observer.dart",
     "src/document/values/compressor.dart",
     "src/document/values/converted_change.dart",
diff --git a/public/dart/sledge/README.md b/public/dart/sledge/README.md
index 4163d17..0d0be3c 100644
--- a/public/dart/sledge/README.md
+++ b/public/dart/sledge/README.md
@@ -82,7 +82,7 @@
 Every `Type` has an associated `Value`, for example:
   * Boolean -> BooleanValue
   * Integer -> IntegerValue
-  * Schema -> ValueNode
+  * Schema -> NodeValue
 
 ### Documents
 
diff --git a/public/dart/sledge/lib/src/document/document.dart b/public/dart/sledge/lib/src/document/document.dart
index 77b74f0..315cb15 100644
--- a/public/dart/sledge/lib/src/document/document.dart
+++ b/public/dart/sledge/lib/src/document/document.dart
@@ -12,7 +12,7 @@
 import 'change.dart';
 import 'document_id.dart';
 import 'leaf_value.dart';
-import 'value_node.dart';
+import 'node_value.dart';
 import 'value_observer.dart';
 import 'values/last_one_wins_value.dart';
 
@@ -36,7 +36,7 @@
 class Document implements ValueObserver {
   final Sledge _sledge;
   final DocumentId _documentId;
-  ValueNode _value;
+  NodeValue _value;
   final Map<Uint8List, LeafValue> _fields;
   final ConnectionId _connectionId;
   static const int _identifierLength = 21;
diff --git a/public/dart/sledge/lib/src/document/leaf_value.dart b/public/dart/sledge/lib/src/document/leaf_value.dart
index 7633704..3858163 100644
--- a/public/dart/sledge/lib/src/document/leaf_value.dart
+++ b/public/dart/sledge/lib/src/document/leaf_value.dart
@@ -9,6 +9,8 @@
 import 'value_observer.dart';
 
 /// Interface implemented by all observable Sledge Values.
+/// See the documentation for the `Value` class for a description
+/// of its role.
 abstract class LeafValue implements Value {
   /// Observes events occurring on this value.
   set observer(ValueObserver observer);
diff --git a/public/dart/sledge/lib/src/document/value_node.dart b/public/dart/sledge/lib/src/document/node_value.dart
similarity index 84%
rename from public/dart/sledge/lib/src/document/value_node.dart
rename to public/dart/sledge/lib/src/document/node_value.dart
index eb8d165..72b5a48 100644
--- a/public/dart/sledge/lib/src/document/value_node.dart
+++ b/public/dart/sledge/lib/src/document/node_value.dart
@@ -8,24 +8,21 @@
 import 'value.dart';
 
 /// Class that maps field names to values.
-/// TODO: rename to NodeValue
-class ValueNode implements Value {
+/// See the documentation for the `Value` class for a description
+/// of its role.
+class NodeValue implements Value {
   Map<String, Value> _childValues;
-  // TODO: remove
-  Map<Symbol, Value> _childValuesDeprecated;
 
   /// Default constructor. [schemaDescription] specifies the name and type of
   /// every field.
-  ValueNode(
+  NodeValue(
       Map<String, BaseType> schemaDescription, ConnectionId connectionId) {
-    _childValuesDeprecated = <Symbol, Value>{};
     _childValues = <String, Value>{};
 
     schemaDescription.forEach((String name, BaseType type) {
       Value value = type.newValue(connectionId);
       assert(value != null);
       _childValues[name] = value;
-      _childValuesDeprecated[new Symbol(name)] = value;
     });
   }
 
@@ -33,7 +30,7 @@
   Map<String, LeafValue> collectFields() {
     final fields = <String, LeafValue>{};
     _childValues.forEach((String name, Value value) {
-      if (value is ValueNode) {
+      if (value is NodeValue) {
         value
             .collectFields()
             .forEach((key, value) => fields['$name.$key'] = value);
diff --git a/public/dart/sledge/lib/src/document/value.dart b/public/dart/sledge/lib/src/document/value.dart
index 337f6d9..dd89102 100644
--- a/public/dart/sledge/lib/src/document/value.dart
+++ b/public/dart/sledge/lib/src/document/value.dart
@@ -3,4 +3,25 @@
 // found in the LICENSE file.
 
 /// Interface implemented by all Sledge Values.
+///
+/// Values are used to store the structure and content of the fields of a
+/// Document.
+///
+/// There are two main types of Values: NodeValues, and LeafValues.
+/// Every Sledge Document holds a reference to a NodeValue.
+/// The NodeValues hold references to at least one other Value (either a
+/// NodeValue or a LeafValue).
+/// The LeafValues store the actual content of the fields.
+///
+/// For example, a Document whose fields can be accessed the following way:
+///   doc['a'].value = 1;
+///   doc['b']['c'].value = 2.0;
+///   doc['b']['d'].value = 'foobar';
+/// Will be composed of 2 NodeValues and 3 LeafValues:
+///   doc
+///    └─NodeValue
+///          ├─ 'a' : LeafValue (specialized for integers)
+///          └─ 'b' : NodeValue
+///                       ├─ 'c' : LeafValue (specialized for doubles)
+///                       └─ 'd' : LeafValue (specialized for strings)
 abstract class Value {}
diff --git a/public/dart/sledge/lib/src/document/values/ordered_list_tree_path.dart b/public/dart/sledge/lib/src/document/values/ordered_list_tree_path.dart
index 8c11a7c..8536cfc 100644
--- a/public/dart/sledge/lib/src/document/values/ordered_list_tree_path.dart
+++ b/public/dart/sledge/lib/src/document/values/ordered_list_tree_path.dart
@@ -12,7 +12,7 @@
 
 // Length of a bytelist, written on edge to value node.
 // Bytelist content is: {1}{timetamp}, {timestamp} is 8 bytes long.
-const _valueNodeSuffixLength = 9;
+const _nodeValueSuffixLength = 9;
 const _listEquality = const ListEquality();
 
 /// Type of child.
@@ -40,14 +40,14 @@
       : this(concatListOfUint8Lists([parent._data]..addAll(labels)));
 
   /// Creates OrderedListTreePath corresponding to tree root.
-  OrderedListTreePath.root() : this(new Uint8List(_valueNodeSuffixLength));
+  OrderedListTreePath.root() : this(new Uint8List(_nodeValueSuffixLength));
 
   /// Checks if node is a child of a [parent].
   bool isDescendant(OrderedListTreePath parent) {
     if (_data.length <= parent._data.length) {
       return false;
     }
-    int prefixLen = parent._data.length - _valueNodeSuffixLength;
+    int prefixLen = parent._data.length - _nodeValueSuffixLength;
     for (int i = 0; i < prefixLen; i++) {
       if (parent._data[i] != _data[i]) {
         return false;
@@ -60,7 +60,7 @@
   OrderedListTreePath parentPath() {
     // Remove appendix corresponding to value from path.
     return new OrderedListTreePath(new Uint8List.fromList(
-        _data.getRange(0, _data.length - _valueNodeSuffixLength).toList()));
+        _data.getRange(0, _data.length - _nodeValueSuffixLength).toList()));
   }
 
   /// Returns OrderedListTreePath representing child of this.
diff --git a/public/dart/sledge/lib/src/schema/schema.dart b/public/dart/sledge/lib/src/schema/schema.dart
index d6a7b23..1bb5618 100644
--- a/public/dart/sledge/lib/src/schema/schema.dart
+++ b/public/dart/sledge/lib/src/schema/schema.dart
@@ -8,8 +8,8 @@
 
 import 'package:collection/collection.dart';
 
+import '../document/node_value.dart';
 import '../document/value.dart';
-import '../document/value_node.dart';
 import '../sledge_connection_id.dart';
 import '../uint8list_ops.dart' as utils;
 import 'base_type.dart';
@@ -93,7 +93,7 @@
 
   @override
   Value newValue(ConnectionId id) {
-    return new ValueNode(_schemaDescription, id);
+    return new NodeValue(_schemaDescription, id);
   }
 
   /// Returns a description of the schema.