Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

object oriented question #226

Closed
matthewchung74 opened this issue Oct 23, 2014 · 2 comments
Closed

object oriented question #226

matthewchung74 opened this issue Oct 23, 2014 · 2 comments

Comments

@matthewchung74
Copy link

I'm wondering in the scaffolding code, looking at articles for example, the controller might have something like exports.create = function(req, res) { which is good, but feels kind of functional opposed to object oriented, ie module.exports = function() { var ctrl = new Articles(); return ctrl; }

I'm curious to hear the reason the scaffolds do it this way opposed to new'ing up an object that that has public/privileged methods exposed?

@rschwabco
Copy link
Member

Check out this talk and see what Douglas Crockford thinks about using "new" and about OOP generally. Specifically, this pattern is consistent with the common usage of Express.js - and as such, we choose to prefer it over alternative styles.

@matthewchung74
Copy link
Author

That video totally changed how I look at JS. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants