Permalink
Browse files

Improved some jsdoc comments and general code cleanup

  • Loading branch information...
Brian Hartsock
Brian Hartsock committed Jun 1, 2011
1 parent ee11b85 commit 8d7e553b48ec248be977c766779e6185bb0ad998
Showing with 37 additions and 28 deletions.
  1. +2 −0 backlog.txt
  2. +3 −3 controllers/add_comment.js
  3. +3 −0 models/comment.js
  4. +22 −4 models/model.js
  5. +0 −13 models/post.js
  6. +4 −4 models/post_repository.js
  7. +2 −2 post.html
  8. +0 −1 post.js
  9. +1 −1 test/models/post_repository_tests.js
View
@@ -5,3 +5,5 @@
* Test fixtures
* Validation
* generators for the code
+* Improve ID strategy
+* Make repository more generic
@@ -9,15 +9,15 @@ goog.require('blog.views.Comment');
goog.require('goog.debug.ErrorHandler');
/**
- * @param {blog.models.Post} post Post to render coment list for
+ * @param {!blog.models.Post} post Post to render coment list for
* @constructor
* @extends {goog.ui.Component}
*/
blog.controllers.AddComment = function(post){
goog.base(this);
/**
- * @type {blog.models.Post}
+ * @type {!blog.models.Post}
* @private
*/
this.post_ = post;
@@ -33,7 +33,7 @@ blog.controllers.AddComment.prototype.createDom = function(){
}
/**
- * @param {goog.events.Event} e Event fired.
+ * @param {!goog.events.Event} e Event fired.
* @private
*/
blog.controllers.AddComment.prototype.onSubmit_ = function(e){
View
@@ -41,6 +41,9 @@ blog.models.Comment = function(name, email, webpage, content){
}
goog.inherits(blog.models.Comment, blog.models.Model);
+/**
+ * @inheritDoc
+ */
blog.models.Comment.prototype.validations_ = {
name: new blog.NotEmptySpecification(),
content: new blog.NotEmptySpecification()
View
@@ -12,18 +12,38 @@ goog.require('goog.events.EventTarget');
* @constructor
*/
blog.models.Model = function(obj){
+
+ /**
+ * @type {string}
+ * @private
+ */
+ this.id_ = '' + Math.floor(Math.random() * 100);
+
if(obj){
this.fromObj_(obj);
}
}
goog.inherits(blog.models.Model, goog.events.EventTarget);
+
/**
- * @type {Object}
- * @protected
+ * @type {Object.<string, blog.Specification>}
+ * @private
*/
blog.models.Model.prototype.validations_ = {};
+/**
+ * @type {Object.<string, Function>}
+ * @private
+ */
+blog.models.Model.prototype.associations_ = {};
+
+/**
+ * @return {string}
+ */
+blog.models.Model.prototype.getId = function(){
+ return this.id_;
+}
/**
* @returns {boolean} True or false depending on validation
@@ -45,8 +65,6 @@ blog.models.Model.EventType = {
MODEL_CHANGED: goog.events.getUniqueId('model_changed')
}
-blog.models.Model.prototype.associations_ = {
-}
/**
* @param {Object} parentType Parent model to map children to
View
@@ -16,12 +16,6 @@ goog.require('goog.events.Event');
blog.models.Post = function(obj){
goog.base(this);
- /**
- * @type {string}
- * @private
- */
- this.id_ = "" + Math.floor(Math.random() * 100);
-
/**
* @type {Array.<blog.models.Comment>}
* @private
@@ -54,13 +48,6 @@ blog.models.Post.EventType = {
COMMENT_ADDED: goog.events.getUniqueId('comment_added')
}
-/**
- * @return {string}
- */
-blog.models.Post.prototype.getId = function(){
- return this.id_;
-}
-
/**
* @param {string} content The content to set.
*/
@@ -10,14 +10,14 @@ goog.require('goog.storage.Storage');
*/
blog.models.PostRepository = function(store){
/**
- * @type {goog.storage.Storage}
+ * @type {!goog.storage.Storage}
* @private
*/
this.store_ = store;
}
/**
- * @returns {Array.<blog.models.Post>}
+ * @returns {Array.<!blog.models.Post>}
*/
blog.models.PostRepository.prototype.getPosts = function(){
var posts_meta = this.getPosts_();
@@ -30,7 +30,7 @@ blog.models.PostRepository.prototype.getPosts = function(){
}
/**
- * @param {blog.models.Post}
+ * @param {!blog.models.Post}
*/
blog.models.PostRepository.prototype.add = function(post){
var posts_meta = this.getPosts_();
@@ -47,7 +47,7 @@ blog.models.PostRepository.prototype.add = function(post){
}
/**
- * @param {blog.models.Post}
+ * @param {!blog.models.Post}
*/
blog.models.PostRepository.prototype.remove = function(post){
var posts_meta = this.getPosts_();
View
@@ -8,7 +8,7 @@
-->
</head>
<body>
- <div id="comment_list" />
- <div id="add_comment" />
+ <div id="comment_list"></div>
+ <div id="add_comment"></div>
</body>
</html>
View
@@ -21,5 +21,4 @@ window.onload = function(){
comment_list.render(goog.dom.getElement('comment_list'));
add_comment.render(goog.dom.getElement('add_comment'));
-
}
@@ -10,7 +10,7 @@ function setUp(){
repository = new blog.models.PostRepository(storage);
}
-function test_can_retrieve_comment_after_adding(){
+function test_can_retrieve_blog_after_adding(){
assertEquals(0, repository.getPosts().length);
var post = new blog.models.Post();

0 comments on commit 8d7e553

Please sign in to comment.