07/10/2009, 08:10 AM
|
#1 (permalink) |
|
Member
![]() ![]() Join Date: Jun 2009
Location: Indianapolis, IN
Posts: 1,686
Likes Received: 0
Thanks: 41
Thanked 365 Times in 215 Posts
|
These seem to be two different styles of JavaScript for WebOS development
Code:
function AppAssistant() {
});
}
AppAssistant.prototype.initialize = function() {
};
AppAssistant.prototype.setup = function() {
};
Code:
AppAssistant = Class.create({
initialize: function(controller){
},
setup: function(){
}
});
|
07/10/2009, 09:18 AM
|
#2 (permalink) |
|
Member
![]() ![]() Join Date: Jun 2009
Location: Silicon Valley, California
Posts: 1,025
Likes Received: 0
Thanks: 37
Thanked 444 Times in 161 Posts
|
The first does seem to be used more for the Assistants. I am not sure if there are any specific benefits over the class.create for the assistants.
Strangely, the Palm devs used the class.create more often for the stock apps, but the sample apps mostly used the AppAssistant.prototypes syntax. However, for custom objects I always use the create.class method as it is definitely more flexible for those purposes. |
07/10/2009, 10:08 AM
|
#3 (permalink) |
|
Member
![]() ![]() Join Date: Jun 2009
Location: Indianapolis, IN
Posts: 1,686
Likes Received: 0
Thanks: 41
Thanked 365 Times in 215 Posts
|
I was noticing the difference between what Palm did and what Palm said.
I have tried it both ways and don't see anything lacking with the later option. Just wondering if I missed something. |
07/10/2009, 10:38 AM
|
#4 (permalink) |
|
Member
![]() ![]() Join Date: Jun 2009
Location: Sunnyvale CA
Posts: 699
Likes Received: 6
Thanks: 19
Thanked 160 Times in 72 Posts
|
It's just a different way of constructing objects. There's no real difference I think except for the second one being a bit more appealing to people with a JAVA background.
|
07/10/2009, 11:12 AM
|
#6 (permalink) |
|
Legend
![]() Join Date: May 2005
Location: Winnipeg, MB, Canada
Posts: 3,883
Likes Received: 496
Thanks: 801
Thanked 12,956 Times in 1,495 Posts
|
Either works I believe. Palm seems to have Prototype built into the framework, so that might be connected. I could be wrong, but it seems just a matter of preference.
Last edited by Jason Robitaille; 07/10/2009 at 01:20 PM. |
07/10/2009, 11:15 AM
|
#7 (permalink) | |
|
Member
![]() ![]() Join Date: Jun 2009
Location: Indianapolis, IN
Posts: 1,686
Likes Received: 0
Thanks: 41
Thanked 365 Times in 215 Posts
|
Quote:
The prototype in this sense is nothing to do with the Prototype framework. It is a JavaScript property to add something to all instances of the object. The first example is building an object and then adding on functionality down the file. The second is creating an object with all the functionality in one swipe. I don't know if there is a performance advantage either way, other than reading and parsing the extra text for the first. There might be an advantage of not messing up the list in the second with a more formal "prototype" version. Last edited by sacherjj; 07/10/2009 at 11:29 AM. |
|
07/10/2009, 12:54 PM
|
#9 (permalink) |
|
Member
![]() ![]() Join Date: Jun 2009
Location: Indianapolis, IN
Posts: 1,686
Likes Received: 0
Thanks: 41
Thanked 365 Times in 215 Posts
|
Ahh. Gotcha. That explains why it was vaguely familiar to me. I messed with Prototype a while back, but not much since.
Last edited by sacherjj; 07/10/2009 at 05:50 PM. |
07/10/2009, 05:26 PM
|
#10 (permalink) |
|
Member
![]() Join Date: Jun 2009
Posts: 204
Likes Received: 18
Thanks: 5
Thanked 18 Times in 14 Posts
|
Dude, thank you for asking this question. I've been wondering the same thing. Although I was under the impression that they both used the prototype framework.
Coming from an ANSI C background (damn you OOP!) I can read the .prototype method a lot more clearly. It just seems to make more sense. For some reason, I feel like I should be reading the class.create method backwards. The use of colons reminds me too much of BASIC. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|



