Skip to main content
edited tags
Link
Alex L
  • 5.8k
  • 2
  • 26
  • 69
Notice removed Reward existing answer by user73428
Bounty Ended with David Harkness's answer chosen by CommunityBot
edited tags
Link
Alex L
  • 5.8k
  • 2
  • 26
  • 69
Tweeted twitter.com/#!/StackCodeReview/status/491059122516004864
Notice added Reward existing answer by user73428
Bounty Started worth 50 reputation by CommunityBot
prototypical -> prototypal and hopefully catchy title (resisted urge to prefix with "probably")
Source Link
David Harkness
  • 8.9k
  • 1
  • 27
  • 44

Proper usage of prototypical code structureprototypal programming with these Node.JS modules?

Practicing PrototypicalPrototypal Code

I'm focusing on practicing a very prototypicalprototypal structure with my code (non library oriented) to begin learning to reuse large portions of my application infrastructures where applicable in future projects. With this in mind, I don't have experience with prototypicalprototypal programming before now, and would like to ensure that I'm not misusing the strategy.

The following server side JavaScript code has the purpose of handling a large number of Socket.io events in a modulated, prototypicalprototypal way. My goal is code that is readable, but also reusable. I feel as if I may be sacrificing the clarity of my code in order to utilize a prototype for the handlers; it eliminates the inclusion of duplicate code in each handler, most of which helps with debug logging, but it may make the code less readable. I'm interested in learning whether or not this is an unavoidable aspect of using prototypes, or if there are ways that I may use prototypes without diminishing readability.

Most importantly, I'm interested in feedback on the comparison between the prototypicalprototypal and non prototypical-prototypal event handling, and whether or not I'm using that strategy correctly.

Non Prototypical-Prototypal Handlers

PrototypicalPrototypal Handlers

Proper usage of prototypical code structure with these Node.JS modules?

Practicing Prototypical Code

I'm focusing on practicing a very prototypical structure with my code (non library oriented) to begin learning to reuse large portions of my application infrastructures where applicable in future projects. With this in mind, I don't have experience with prototypical programming before now, and would like to ensure that I'm not misusing the strategy.

The following server side JavaScript code has the purpose of handling a large number of Socket.io events in a modulated, prototypical way. My goal is code that is readable, but also reusable. I feel as if I may be sacrificing the clarity of my code in order to utilize a prototype for the handlers; it eliminates the inclusion of duplicate code in each handler, most of which helps with debug logging, but it may make the code less readable. I'm interested in learning whether or not this is an unavoidable aspect of using prototypes, or if there are ways that I may use prototypes without diminishing readability.

Most importantly, I'm interested in feedback on the comparison between the prototypical and non prototypical event handling, and whether or not I'm using that strategy correctly.

Non Prototypical Handlers

Prototypical Handlers

Proper prototypal programming with Node.JS

Practicing Prototypal Code

I'm focusing on practicing a very prototypal structure with my code (non library oriented) to begin learning to reuse large portions of my application infrastructures where applicable in future projects. With this in mind, I don't have experience with prototypal programming before now, and would like to ensure that I'm not misusing the strategy.

The following server side JavaScript code has the purpose of handling a large number of Socket.io events in a modulated, prototypal way. My goal is code that is readable, but also reusable. I feel as if I may be sacrificing the clarity of my code in order to utilize a prototype for the handlers; it eliminates the inclusion of duplicate code in each handler, most of which helps with debug logging, but it may make the code less readable. I'm interested in learning whether or not this is an unavoidable aspect of using prototypes, or if there are ways that I may use prototypes without diminishing readability.

Most importantly, I'm interested in feedback on the comparison between the prototypal and non-prototypal event handling, and whether or not I'm using that strategy correctly.

Non-Prototypal Handlers

Prototypal Handlers

deleted 1022 characters in body
Source Link
user73428
user73428
Loading
deleted 57 characters in body
Source Link
user73428
user73428
Loading
This type of implied request doesn't need to be in the title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Loading
edited body
Source Link
user73428
user73428
Loading
edited body
Source Link
user73428
user73428
Loading
deleted 2 characters in body
Source Link
user73428
user73428
Loading
added 214 characters in body
Source Link
user73428
user73428
Loading
added 214 characters in body
Source Link
user73428
user73428
Loading
Source Link
user73428
user73428
Loading