Results 1 to 5 of 5

Thread: programming problem

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default programming problem

    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

    Code:
    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 ?

  2. #2
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
      0  

    Default

    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.

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default

    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 ?

  4. #4
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
      0  

    Default

    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...

  5. #5
    Sencha User
    Join Date
    Jul 2010
    Posts
    304
    Vote Rating
    0
      0  

    Default

    Thank you Friend I am reassured

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •