PDA

View Full Version : programming problem



flamant
19 May 2011, 8:41 AM
Hi,
I am wondering if when we have config option property that has not a setter method we can change it dynamically.

For example ComboBox has a allowBlank config Options property and we cannot change it by a method

In my code I change it dynamically depending on certain cases



combo.allowBlank = false;


Is it good or bad programming practice

Is that only reserved to public properties or can it be applied to config options property ?

friend
19 May 2011, 8:49 AM
This is strictly personal opinion, but I don't see any harm in manipulating object attributes directly, so long as you don't corrupt the state of the object.

Like you, I have quite a few scenarios where I directly manipulate allowBlank, based on user selections made in a form.

flamant
19 May 2011, 8:58 AM
Thank you friend for your answer

I had a hard discussion with my boss who said that it is poor programming practice

Do you know somebody who is a referal in EXTJS that can tell me if it is or it is not the case. Maybe you are very experimented ?

friend
19 May 2011, 9:05 AM
You can always point out to him that the API doesn't provide setters/getters for all object attributes, so it leaves these attributes publicly visible so that you can manipulate them.

You might also remind him that this is Javascript; a typeless, dynamic, prototype-driven language which doesn't quite support full-on inheritance, polymorphism, etc (it kinda does, but then again, it'd kinda doesn't).

And as one last point: if application requirements dictate that a field be dynamically toggled to require/not require a value and there's no other way to do it, then directly manipulating an object's attribute becomes a requirement...

flamant
19 May 2011, 9:49 AM
Thank you Friend I am reassured