How do you organize your code?

Surprisingly this question has been asked multiple times during interviews. My first response is, “hmm, doesn’t everyone pretty much do the same thing? you use folders and files”

I would normally say, for Backbone, we have index.html, folders for js, css and images. Inside js, there are a main entry file, and then there are folders for models, views, collections, routes and templates. For express.js, even there is no convention, we tried to have folders for models, views, controllers, and routes.

There must be better answers. Should I mention require.js? Or the export and require in node.js? Or should I mention module pattern ?

Of course, there is a StackOverflow answer for it: http://stackoverflow.com/questions/1344605/how-do-you-organize-your-javascript-code

Advertisements
Standard