I am starting my research with these two articles by Douglas Crockford:
The first object I have to create is to represent a kestrel nest box. (Want to build one? - A real box, not a JS object to represent one- Instructions here) The box has parameters including height, width, depth, height off ground, entrance diameter, direction the entrance faces, what the box is mounted on, and more.
My current project will allow researchers across North America (and maybe South America too) to track data from their kestrel boxes. Using OOP and MVC methods will be essential to keep the software flexible enough to satisfy the preferences of such a diverse audience and allow future expansion of the project.
Update 10:35
More valuable references:
https://developer.mozilla.org/en/JavaScript/Guide/Working_with_Objects
https://developer.mozilla.org/en/JavaScript/Guide/Details_of_the_Object_Model
https://developer.mozilla.org/en/JavaScript/Guide/Inheritance_Revisited
Update 17:40
I successfully met my goal. In some ways it was easier than expected, but at the same time, a bit confusing. My object is created simply by retrieving the parameters from the database, via jQuery's Ajax functionality, as JSON.
var request = $.ajax({
url: "getBoxParams.php",
type: "POST",
data: {id : nestBoxClicked, user: userToken},
dataType: "JSON"
});
request.done(function(boxData) {
var kbox=new nestBox(boxData);
url: "getBoxParams.php",
type: "POST",
data: {id : nestBoxClicked, user: userToken},
dataType: "JSON"
});
request.done(function(boxData) {
var kbox=new nestBox(boxData);
populateBoxForm(kbox);
});
});
Then, I manipulate the object properties in the populateBoxForm() function.
I still prefer working with strongly typed languages and classes, but it appears JavaScript can do what I need for a fully-functional web app, without losing speed or user-friendliness.
Douglas Crockford's article about JavaScript code conventions is another good resource I found today.
No comments:
Post a Comment