Do I prototype my objects with my properties and methods or do I just add properties in the constructor?
Think of it this way. The "prototype" methods and properties are always a part of your objects. Create a property or method
without the prototype keyword if you want to
decorate an existing object. Why? Because the more you prototype, the heavier the object becomes, so... prototype carefully. I guess an exception to this is if you are creating a singleton class, prototyping is probably not necessary as it is not instantiated so just going this.SomeMethod = ... is fine. Anybody have comments on that?
The
Prototype JS framework is great but all the "prototyping" creates heavier objects that inherently might not have been as heavy. As well by prototyping an inherent data type like Object, you risk breaking existing JavaScript code that tries to integrate with a framework like Prototype because it's "prototype"ed all these new properties and methods on HTMLElements or the Object inherent data types.
Having said all that, JavaScript frameworks are great for
RAD deployment, but I still stick by my guns when I say that with lots of data and objects on a page, this heavily protoyped framework mindset definitely slows things down. See
my original post.