1. RE: Best Practices Issue
- Posted by Jonas Temple <jktemple at yhti.net> Feb 07, 2003
- 398 views
I will typically use the value directly from the control if I only need to reference the value 1 or 2 times top. If I need to reference the value in another routine (maybe with a global variable) or need to reference the value more than 2 times within a function I'll assign to a variable. This reduces clutter, makes the code easier to read and also allows me to ? the value of the variable in debug. It also helps with performance as you're not having to call getText() multiple times. Jonas C. K. Lester wrote: > Okay, time for everybody to express their opinion... > > In what circumstances, if any, might you allow controls to take the > place of > variables? In what circumstances, if any, might you not? > > Simple Example: > > I have a window with a single edit text control. A user types '3' into > it. > There are two ways to deal with this value: 1) Assign it to a variable > and > use it that way, or 2) use it directly from the control (no variable > required). > > So, what do you do and why? > >