What would be the best (performance, memory wise) to achieve a clean way to create a class or some way to properly structure the code, that shares 2 variables (req, res) which have a decent object size.And yes, for those who use Node.js it are the req and res variables, but it is irrelevant.This is what I tried so far:function Client(req, res){  var self = this;  self.req = req;  self.res = res;  route.call(self);  handleRoute.call(self);  handleRequestData.call(self);}function route(){  var self = this;  self.req.route = // ...}function handleAuth(){  var self = this;  self.req.auth = // ...}function handleRequestData(){  var self = this;  self.req.data = // ...}I am wondering if it could be improved, since I mentioned req and res are pretty decent objects with methods, properties. Since .call(self) you pass through the instance, would it be most effective way?Also I don't like using var self = this; all the time, it is useless. And btw, I don't want to use Coffeescript.Solution 1. (fails because of the massive passing through req and res)Lets assume we got to files 1. client.jsvar Client = {  route: function(req, res){},  auth: function(req, res, callback){ callback(req, res); },  getData: function(req, res, callback){ callback(req, res); } // async}file 2. main.jsvar client = require('./client.js');client.route(req, res); // fine because this is syncronous.// This is where the problem is, massive passing through req and res parameters.client.auth(req, res, function(req, res){  client.getData(req, res, function(req, res){    // Do something...  });});
Structuring code to do URL routing for Node.js
javascript;object oriented;url routing