[NebraskaJSLightningTalk initWithPresentorIntroduction:[NEJSSeanLarkinUser giveExceptionalIntroduction]];
Nebraska JS, Lincoln, NE, 2015
Sean Larkin, UI/UX Developer at Infogroup
@TheLarkInn : twitter/codepen/github
Readability Junky
My mom really likes the chicken selfies...
- Jamie Talbot
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." — The Pragmatic Programmer
var Category = function(objectProperties) {
this.childCategory = objectProperties.childCategory || [];
this.name = objectProperties.name || "";
this.description = objectProperties.description || "";
}
Category.prototype.getChildCategoryName = function() {
if (!this.childCategory instanceof Category) {
throw("Child Category is not of instance Category")
}
return this.childCategory.name;
}
Category.prototype.getChildCategoryDescription = function() {
if (!this.childCategory instanceof Category) {
throw("Child Category is not of instance Category")
}
return this.childCategory.description;
}
var Category = function(objectProperties) {
this.childCategory = objectProperties.childCategory || [];
this.name = objectProperties.name || "";
this.description = objectProperties.description || "";
}
Category.prototype.validateChildCategoryInstance = function() {
if (!this.childCategory instanceof Category) {
throw("Child Category is not of instance Category");
}
}
Category.prototype.getChildCategoryName = function() {
this.validateChildCategoryInstance();
return this.childCategory.name;
}
Category.prototype.getChildCategoryDescription = function() {
this.validateChildCategoryInstance();
return this.childCategory.description;
}
Descriptive
And
Meaningful
Phrases
To maintain code, you first need to understand the code. To understand it, you have to read it. Consider for a moment how much time you spend reading code. It’s a lot. DAMP increases maintainability by reducing the time necessary to read and understand the code. — Chris Edwards
Maintain
Understand
Read
//dataLog.js
var data = [1, 3, 4, 6, 7, 9];
var logData = function(data) {
data.each(function(i, idx) {
console.log(i);
});
};
logData(data);
//Off to a great start... :(
//logData.js
// What is this data for? If it wasn’t defined here, would we know
// what data type it is?
var data = [1, 3, 4, 6, 7, 9];
// What kind of data are we logging?
// What is the data type of the argument?
var logData = function(data) {
// What are the arguments inside the each function?
data.each(function(i, idx) {
console.log(i, idx);
});
};
// Well at-least I know something happens here...-_-'
logData(data);
//slPrintChildArrayNamesModuleButCommentsAreNotNeededWhenYouProgramWithDAMPFundementals.js
var childAgesArray = [1, 3, 4, 6, 7, 9];
var logEachAgeInArray = function(agesArray) {
agesArray.each(function(ageInteger, index) {
console.log(ageInteger, index);
});
};
logEachAgeInArray(childAgesArray);
//slPrintChildArrayNamesModule.js
var childAgesArray; //Guts get assigned here
var logEachAgeInArray = function(agesArray) {
//Guts here
};
logEachAgeInArray(childAgesArray);
function hnGutlessPredictiveSearchCtrl($scope) {
// ... omitted for brevity
$scope.inputValueIsPreFilledFromNttParam = GUTS
$scope.requestedSearchTermForHighlighting = GUTS
$scope.searchAsYouTypeArray = GUTS
$scope.indexOfLastItemInSearchAsYouTypeArray = GUTS
$scope.selectedSearchTermResultIndex = GUTS
$scope.searchQuery = GUTS
$scope.searchAsYouTypeRequestDidRespondWithSuccess = function(data, status, headers, config) {
GUTS
};
$scope.searchAsYouTypeRequestDidRespondWithError = function(data, status, headers, config) {
GUTS
};
$scope.shouldBeHighlightedBasedOnResultTypeAndTypeIndex = function(resultType, typeIndex, nameValue) {GUTS};
$scope.upArrowKeyPressed = function() {GUTS};
$scope.downArrowKeyPressed = function() {GUTS};
$scope.setSelectedIndexViaMouseOver = function(resultType, typeIndex) {GUTS};
$scope.submitProductCategoryToAnalytics = function(productCategory, $event) {GUTS};
$scope.submitSuggestionToAnalytics = function(suggestion, $event) {
GUTS
};
// ... omitted for brevity
};
copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:destinationBytesPerRow:destinationBytesPerImage:
AVCaptureManualExposureBracketedStillImageSettings
AVCaptureAutoExposureBracketedStillImageSettings
AVAudioEnvironmentDistanceAttenuationParameters
usesAirPlayVideoWhileAirPlayScreenIsActive
navigationControllerPreferredInterfaceOrientationForPresentation:
NSDidDAMPExitFromPresentation