Created
February 17, 2011 21:37
-
-
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)
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
// 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