Skip to content

Instantly share code, notes, and snippets.

@Olegas
Last active August 29, 2015 14:09
Show Gist options
  • Save Olegas/4eb23b3bad0658ebde0d to your computer and use it in GitHub Desktop.
Save Olegas/4eb23b3bad0658ebde0d to your computer and use it in GitHub Desktop.
How code style affects code review
{
/**
* Получить контрол по идентификатору.
* @param {String} id Идентификатор искомого контрола.
* @return {$ws.proto.Control} Найденный контрол.
* @deprecated Используйте $ws.proto.AreaAbstract.getChildControlByName
*/
get : function(id){
if (this._storage[id] === undefined)
throw new Error("ControlStorage : id = '" + id + "' not stored");
return this._storage[id];
}
}
this.doWork({ amount: 5, unit: "hour" })
function bubbleSort(r){var o;do{o=!1;for(var a=0;a<r.length-1;a++)if(r[a]>r[a+1]){var b=r[a];r[a]=r[a+1],r[a+1]=b,o=!0}}while(o)}
function bubbleSort(array, direction) {
// ...
}
function quickSort(direction, array) {
// ...
}
function mergeSort(compareFunc, array) {
// ...
}
this.doWork({
amount: 5,
unit: "hour"
})
function replaceTokens(str) {
if (typeof str !== 'string') {
// try to fix or throw error
}
return str.replace(/(some|token|regexp)/g, 'tok-$1');
}
function srt(x)
{
var a;
do {
a = false;
for (var b=0; b < x.length-1; b++) {
if (x[b] > x[b+1]) {
var c = x[b];
x[i] = x[b+1];
x[b+1] = c;
a = true;
}
}
} while (a);
}
/**
* Сортировка пузырьком
* Изменяет переданный массив
*
* @param {Array} array массив для сортировки
*/
function bubbleSort(array)
{
var swapped;
do {
swapped = false;
for (var i=0; i < array.length-1; i++) {
if (array[i] > array[i+1]) {
var temp = array[i];
array[i] = array[i+1];
array[i+1] = temp;
swapped = true;
}
}
} while (swapped);
}
if (!(ctxVal === null && !self.isAllowEmpty()) &&
(ctxVal !== self._notFormatedVal() ||
self._valueSet === false &&
ctxVal !== self._desiredDefaultValue)) {
// do something
} else {
// WAT?????
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment