こんばんは、JSが好きな鈴木晋と申します。 https://github.com/shinout

JSはやわらかいので色々なやり方があるかと思われます。
ぱっと思いついたのを書きます。もうすでに案として上がっているものかもしれませんが...。
なお、ベストプラクティスについては存じません...。

// forEach
[io, ios].forEach(function(io) {
  io.set("log level", 0);
   // and so on...
})

// 関数を使う
function ioBuildUp(io) {
  io.set("log level", 0);
   // and so on...
}
ioBuildUp(io);
ioBuildUp(ios);

//もう最初っから、違う部分と同じ部分を徹底的にわけてしまう
// 汎用性ありそうで実はないというものの典型
function createIO(app, options) {
  var protocol = options.protocol;
  var port       = options.port;
  var server = require(protocol).createServer(app).listen(port);
  delete options.protocol, delete options.port;
  var io = require("socket.io").listen(server, options);

  io.set("log level", 0);
  // and so on ....
  return io;
}
var io   = createIO(app, { protocol: "http", port: 80 });
var ios = createIO(app, { protocol: "https", port: 443, key:https_key,
cert: https_cert });

大幅にロジックを間違えなければ、メモリ使用率とかよりも
保守性可読性を優先して決めて良い部分だと思います。

失礼いたしました。

-- 

--- 
このメールは Google グループのグループ「Node.js 日本ユーザグループ」の登録者に送られています。
このグループから退会し、メールの受信を停止するには、nodejs_jp+unsubscr...@googlegroups.com にメールを送信します。
その他のオプションについては、https://groups.google.com/groups/opt_out にアクセスしてください。


メールによる返信