Relative Content

Tag Archive for naming-standards

How to name a function that makes sure an element exists and returns it?

function getOrInsertEmptyElemById(id){ var elem = $(id) || document.body.insert(‘<div id=”‘+id+'”></div>’); return elem; } I find myself using functions like the above quite often. But I struggle on naming them. How is a make sure it exists and return function usually named? design-patterns naming naming-standards It’s a guard or a guard function. The idea is that checks […]

How to name a function that makes sure an element exists and returns it?

function getOrInsertEmptyElemById(id){ var elem = $(id) || document.body.insert(‘<div id=”‘+id+'”></div>’); return elem; } I find myself using functions like the above quite often. But I struggle on naming them. How is a make sure it exists and return function usually named? design-patterns naming naming-standards It’s a guard or a guard function. The idea is that checks […]

How to name a function that makes sure an element exists and returns it?

function getOrInsertEmptyElemById(id){ var elem = $(id) || document.body.insert(‘<div id=”‘+id+'”></div>’); return elem; } I find myself using functions like the above quite often. But I struggle on naming them. How is a make sure it exists and return function usually named? design-patterns naming naming-standards It’s a guard or a guard function. The idea is that checks […]