Skip to content

Instantly share code, notes, and snippets.

View heymichaelp's full-sized avatar

Michael Phillips heymichaelp

View GitHub Profile
@heymichaelp
heymichaelp / determineStudentPassingStatus.js
Last active April 11, 2016 07:44
Service Objects: Implementation
var _ = require('underscore');
/**
* For a given student, determine whether or not they are passing
* @constructor
* @param {Object} student - The student that being evaluated.
*/
var DetermineStudentPassingStatus = function(student) {
this.student = student;
}
@heymichaelp
heymichaelp / valueObjects1.js
Last active August 29, 2015 14:02
Value Objects: Example
// Primitives
var foo = 2;
var bar = 2;
foo === bar; // => true
// Object identity
var foo = new Number(2);
var bar = new Number(2);
foo === bar; // => false
@heymichaelp
heymichaelp / valueObjects3.js
Last active August 29, 2015 14:02
Value Objects: Example
var myGrade = new Grade(0.65);
alert('My Grade is ' + myGrade + '!'); // alerts, 'My Grade is 0.65!'
var myOtherGrade = new Grade(0.75);
myGrade < myOtherGrade; // true
@heymichaelp
heymichaelp / grade.js
Last active August 29, 2015 14:02
Value Objects: Implementation
var _ = require('underscore');
var Grade = function(percentage) {
this.percentage = percentage;
this.grade = this.grade(percentage);
};
Grade.prototype = _.extend(Grade.prototype, {
passingGradeLetters: function() {
@heymichaelp
heymichaelp / grade.test.js
Last active August 29, 2015 14:02
Value Objects: Testing
var Grade = require('./grade');
var grade1;
var grade2;
describe('Grade', function() {
describe('#isPassing', function() {
it('returns true if grade is passing', function() {
grade1 = new Grade(0.8);
@heymichaelp
heymichaelp / valueObjects4.js
Last active August 29, 2015 14:02
Value Objects: Example
var myGrade = new Grade(0.65);
var myOtherGrade = new Grade(0.65);
myGrade === myOtherGrade; // false
@heymichaelp
heymichaelp / valueObjects2.js
Last active August 29, 2015 14:02
Value Objects: Example
var firstStudent = {grade: new Grade(0.45)};
var secondStudent = {grade: new Grade(0.70)};
firstStudent.grade.isPassing() //=> false
firstStudent.grade.isBetterThan(secondStudent.grade); //=> false
scp [email protected]:/srv/bidkind/shared/log/* logs/
mongodb://userMJzqT7:[email protected]:10243,candidate.12.mongolayer.com:10239/bidkind-staging-elastic
var IssueGrades = function( gradedAssignments ) {}
IssueGrades.prototype = {
run: function() {
alert('issued!');
return gradedAssignments;
}
}