ЙажаСценарий / Говнокод #3016 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
function AbstractControl_getProperty (propertyName) {
	var targetElement = this.getTargetPath(propertyName);
	var result = null;
	
	if (this.isTargetAttribute(propertyName)) {
		eval("result = targetElement." + this.getAttributeName(propertyName));
	} else {
		var getter = this.getGetterName(propertyName);
		var expression = "result = targetElement." + getter + "();";
		eval(expression);
	}
	return result;
}

Вот так наши "суровые челябинские" программисты, не имеющие представления об интроспективности javascript-а, повсюду злоупотребляют eval-ом, усложняя отладку и понимание кода.
По хорошему, вместо первого eval-а должно бы быть:
result = targetElement[this.getAttributeName(propertyName)];
а вместо второго:
result = targetElement[this.getGetterName(propertyName)]();

Запостил: Andronix Andronix, (Updated )

Комментарии (15) RSS

Добавить комментарий

Помни, guest, за тобой могут следить!

    А не использовать ли нам bbcode?


    8