HTML and CSS Reference
In-Depth Information
* @alias app.model.movie
* @constructor
* @param {String} title
* @param {String} rtid
* @param {String} posterframe
* @param {String} synopsis
*/
app.model.movie = function appModelMovie(title, rtid, posterframe, synopsis) {
/**
* The video's instance variables
*/
var _title,
_rtid,
_posterframe,
_synopsis,
_releaseDate,
_videos = [],
_actors = [],
_rating,
_favorite = false,
_self = this;
}
Your complete Movie model should look like the code snippet in Listing A-1 in
the appendix.
The code for this model is very simplistic. For something that's quite crucial to
the application, it makes sense to validate values passed to accessors to
prevent the application from falling over when the wrong type is passed to a
model.
Validation
JavaScript, unfortunately, doesn't support what is known as type hinting. Type
hinting is the process of specifying what type of parameter a method can
accept. Type hinting in other languages will allow you to specify that a
parameter for a method should be a certain type in the method declaration. For
instance, in PHP, you can specify that a parameter should be an array or object
type as shown in the following code snippet.
function doSomething(MyObject $object, array $myarray){
/** some implementation **/
}
 
Search WWH ::




Custom Search