78
I would like to know if the module pattern or constructor/prototype pattern is more applicable to my work.
Basically I am using unobtrusive JavaScript code, and the HTML document has a reference to the .js file.
My understanding of the module pattern:
- call an INIT method (which is basically a public method i can create and return using the module pattern)
- In the INIT method, assign all click events, etc.
This sounds like the perfect pattern for my situation, as I don't need to create Objects, inheritance hierarchies, etc.
My understanding of the constructor/prototype pattern:
- for creating objects
- for using inheritance (i.e., subtypes of a supertype)
Am I correct, that for providing unobtrusive JavaScript code, the module pattern is ideal?