On Mar 2, 2013, at 13:06, David Heller wrote: > I noticed in the code you were using exports.function_name inside a > class. I have seen where exports.function_name would have been written as > class_name.prototype.function_name > and exports.class_name and then end of the script to export the class. What > are the pros and cons of each??
I don't really understand the question. The only place in the code I wrote where I made a class was in the GTCM_GNP module, and the reason I did that is because GTCM_GNP was a class in the PHP version, and I didn't see any of its code, so I don't know what all it does, so I can't make any decision about whether that should be changed or not. In JavaScript, you define a class by defining its constructor function, which I did with "function GTCM_GNP". I then assigned that function to module.exports, so that the GTCM_GNP module becomes this class. I could have directly written "module.exports = function ..." on the first line but often you want to modify the class further, for example to add more methods, and to do that, you modify the constructor function's prototype, and I felt that would be easier to do if you didn't have to keep repeating "module.exports". In the connectionManager module, I exported three individual functions. These functions match the behavior of the PHP methods you showed me, without the need to have a class. Of course I haven't seen the rest of your PHP code so I don't know if there might be some other reason why you would want that to be a class. -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
