New topic: 

Am I doing it right?

<http://forums.realsoftware.com/viewtopic.php?t=46832>

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        Antonio          Post subject: Am I doing it right?Posted: Tue 
Feb 05, 2013 8:11 pm                         
Joined: Sat Feb 04, 2012 1:26 pm
Posts: 84
Location: Italy                Hi,
I have a window containing a tabpanel control with 5 tabs, each containing a 
listbox.
As for  populating the different 5 listboxes, the code is all written inside 
the window's open event. So all the listboxes are populated as the window opens.
Am I doing right or it is better to put the code populating each of the 5 
listboxes inside of each single listbox's open event?
Thank for suggestions.   
                             Top                ktekinay          Post subject: 
Re: Am I doing it right?Posted: Tue Feb 05, 2013 9:58 pm                        
         
Joined: Mon Feb 05, 2007 5:21 pm
Posts: 429
Location: New York, NY                Either works, or you could put it in the 
tab control so a ListBox is populated only if a user views it. There is no 
point in populating a ListBox that the user never needs, right?      
_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.
  
                             Top                Antonio          Post subject: 
Re: Am I doing it right?Posted: Wed Feb 06, 2013 1:17 pm                        
 
Joined: Sat Feb 04, 2012 1:26 pm
Posts: 84
Location: Italy                Kem,
Maybe, putting the code into the "closest" control, helps with the future  
mainteinance, besides it looks  more oop ?. So far, I have tryed to have a 
program that works, and thank to the great help received on this forum I can do 
and understand many things than before. Now I am trying to be more efficient 
and to code in the right manner. My code seems to me to be a little massy. And 
it begins to be difficult to understand where something starts or ends.
P    
                             Top                charonn0          Post subject: 
Re: Am I doing it right?Posted: Wed Feb 06, 2013 1:47 pm                        
         
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1108
Location: San Francisco, CA, USA                As a general rule, putting code 
that deals with a control as near as possible to the control is a good one. 
Another way of saying it is that a particular block of code should only need to 
know about the part of the program that it belongs to. This embodies two 
related object-oriented patterns: encapsulation and information hiding. 

Contrast these two patterns with the don't repeat yourself (DRY) principle. If 
you have a single block of code that changes only slightly and is used in  
several locations, turn it into a method and put the method somewhere that is 
accessible to all the locations in your design where it is needed (see next 
paragraph about using scope.) You can design these helper methods to be generic 
enough to handle all the slightly-different scenarios that a piecemeal design 
would handle, with bug-fixes and enhancements requiring only the change of a 
single method rather than hunting through unrelated code for dozens of slightly 
different code snippets.

If you use RS's object scoping rules, you can prevent certain methods, objects, 
properties, etc. from being accessible beyond a limited area of your program 
(further reading: object scope).

By designing your program with these (and other) patterns, you will find that 
complicated designs are easier to implement and maintain, and that you will be 
able to re-use whole segments of code in completely different applications.     
 
_________________
Boredom Software  
                             Top                Antonio          Post subject: 
Re: Am I doing it right?Posted: Wed Feb 06, 2013 4:10 pm                        
 
Joined: Sat Feb 04, 2012 1:26 pm
Posts: 84
Location: Italy                I think I got the picture, now. I'll study the 
pages you provided me with and will do some practice modifying  my code,
Thabks a lot and Best regards,
Antonio   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to