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
// full source is at https://github.com/liammclennan/Client-Side-JavaScript-MVC-Framework | |
// framework makes available two global variables: app and views | |
// Step 1: Define views. If a requested view is not defined then the framework gets the template from /views/[viewname] | |
views.welcome = function() { | |
var template = " \n\ | |
#container \n\ | |
%ul \n\ |
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
public bool IsValid() | |
{ | |
return true; | |
} |
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
// tell don't ask means I might do something like this | |
var folder = new Folder("foo"); | |
folder.Delete(); | |
// but for that to work the folder class needs to depend on a file IO service (to do the deleting). | |
// the alternative is procedural | |
public class FolderService | |
{ |
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
Language Features | |
Overview | |
Truthyness | |
Closure | |
Lexical Scoping | |
Function Prototypes | |
Reflection | |
JSON | |
Eval |
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
// setup a specification | |
var specification = new UserWithClientSpecification(userId); | |
var userWithClient = userService.RetrieveWithSpecification(specification); | |
// and the specification class would be... | |
public class UserWithClientSpecification : ISpecification<User> | |
{ | |
public UserWithClientSpecification(int userId) |
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
[Test] | |
public void CollectionTests() | |
{ | |
var letterList = new List<string> | |
{ | |
"a","b" | |
}; | |
IEnumerable<string> letters = letterList.Select(l => | |
{ |
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 myNamespace = myNamespace || {}; | |
myNamespace.MyConstructor = function(opts) { this.options = opts; }; | |
(function () { | |
function myPrivateMethod(t) { | |
console.log("myPrivateMethod" + t.options.a); | |
} |
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.prototype._methods = function() { | |
var methods = []; | |
for (m in this) { | |
if (typeof this[m] === 'function' && m !== '_methods' && m !== '_properties') { | |
methods.push(m); | |
} | |
} | |
return methods; | |
} | |
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
story("do a thing", function() { | |
scenario("when I do something under certain conditions", function() { | |
given("certain conditions", function() { | |
console.log("certain conditions"); | |
}); | |
when("I do something", function() { |
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
function Person(name, age) { | |
this.name = name; | |
this.age = age; | |
} | |
Person.prototype = { | |
toString: function() { | |
return this.name + " is " + this.age + " years old."; | |
} | |
}; |
OlderNewer