Created
October 28, 2010 11:09
-
-
Save adamsilver/651119 to your computer and use it in GitHub Desktop.
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
var Field = function() { | |
this.validate = function() { | |
// ... | |
} | |
} | |
// the form holds many fields but they both have the same named public method "validate" | |
var FormValidator = function() { | |
var fields = []; | |
// ... | |
// store field instances in above array | |
// ... | |
this.validate = function() { | |
// loop through all instances of a Field | |
// calling a method on field instance | |
fields[i].validate(); | |
} | |
} | |
// so i can do one or both of the following | |
new FormValidator().validate(); | |
new Field().validate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment