Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Created February 17, 2011 21:37
Show Gist options
  • Save unscriptable/832768 to your computer and use it in GitHub Desktop.
Save unscriptable/832768 to your computer and use it in GitHub Desktop.
if javascript modules mimicked pascal (see http://www.functionx.com/objectpascal/Lesson13.htm)
// Object Pascal separates each unit (file) into two main sections:
// interface and implementation.
// interface declares all of the publicly-facing stuff and has a
// list of dependencies (uses) implementation is the actual code
// and is private. it can have additional dependencies that the
// the interface doesn't have (and it's a good idea to keep as
// many out of the interface as possible to prevent circular
// dependencies).
module('optional name')
.uses([]) // list of dependencies needed by interface
.interface(
/* expose public objects, constructors, or functions here */
)
.uses([]) // list of dependencies needed by implementation
.implementation(
/* bulk of code goes here */
);
// This model doesn't seem to fit well with most javascript
// patterns, which typically mix interface and implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment