-
-
Save theleoborges/1686173 to your computer and use it in GitHub Desktop.
Chapter 5 example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I guess I'd go with straight functions into a module you could mixin or use directly OR objects... | |
//On the first option, something like this: | |
var app = app || {}; | |
app.server = app.server || {}; | |
app.server.http = function() {...}; | |
app.server.get = function() {...}; | |
app.server.post = function() {...}; | |
//And for the second option: | |
var app = app || {}; | |
app.server = function() { | |
that = {}; | |
that.http = function() {...}; | |
that.get = function() {...}; | |
that.post = function() {...}; | |
return that; | |
}(); | |
// I personally prefer the latter. But just because it gives you a chance of having privacy across the | |
// server object. | |
// However, being just a collection of functions, the first could work just as well. | |
// All in all you're dealing with objects anyway, just creating them differently. | |
// Either way, I don't think I'd use classes. | |
// But that's me talking about straight JS. Maybe it'd make sense in CoffeeScript, | |
// given people are usually not familiar with FP. - I wasn't until recently ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment