Quote:
Originally Posted by candybar
A table object needs to be able to get record objects stored in the table and a record object needs to be able to get related records (via foreign key) in other tables. But since it's ridiculous to have those preloaded when the record object is constructed, these should return promises. But if I take that too far, almost every property should return a promise.
I'm not sure that this is correct. Promises are only used for async operations. I don't know which properties you're referring to or how they're being used, but unless each is a separate and distinct asyncronous operation, there shouldn't be a promise attached.
On the other hand, if each property is from a separate async operation, and there are many, you probably should reconsider your overall design and how you're sending and parsing data from the server.
Are you using jQuery? Also, is there a particular reason why you're using promises for handling async development instead of callbacks?
Quote:
Originally Posted by candybar
On a related note, do you guys use a lot of javascript's prototype-based OO features or do you tend to use javascript objects as more of an open bag of properties and have behavior defined outside of prototypes, as you would do in procedural/functional languages? Again, for this project, I'm biased towards using more of javascript's unique features because I want to learn the language very well but it seems like using the more advanced features would be difficult for production web applications because of the need to support legacy browsers).
This is a good question, and I think it depends heavily on the particular situation. Despite being an OO language, many people treat JS exclusively as procedural. And that's fine in spots where you only need simple functionality. But, when you're writing plugins or need more advanced capabilities like inheritance, encapsulation, etc., it fails.
Personally, I like using the constructor pattern in Javascript. Here's a pretty good intro to that, as well as several other design patterns:
http://addyosmani.com/resources/esse...ernsjavascript