Results 1 to 10 of 10
  1.    #1  
    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(){
    
    	}	
    });
    The first seems to be used more, but the second is more space efficient. Which do you prefer and why?
  2. #2  
    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.
  3.    #3  
    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.
  4. #4  
    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.
  5. #5  
    I'm using the second one because it just looks better.
  6. #6  
    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.
  7.    #7  
    Quote Originally Posted by Jason Robitaille View Post
    Either works I believe. Palm seems to have Prototype built into the framework and is a viable option. One just seems to be done with Prototype and the other seems without it. I could be wrong, but it seems just a matter of preference.

    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.
  8. #8  
    The class.create syntax is part of the Prototype framework. The .prototype in the assistants is just plain old javascript.
  9.    #9  
    Quote Originally Posted by Blubble View Post
    The class.create syntax is part of the Prototype framework. The .prototype in the assistants is just plain old javascript.
    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.
  10. #10  
    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.

Posting Permissions