Nigel, Nice post. I very much agree with pretty much all your points. A few things I'll add:
Functions: yes! A lot of IP vars I see in old code are used to make values available that used to take measurable time to derive. Lots of them can be replaced with a short function to just go get the current value of whatever. This is a fine solution for user entry situations. In a tight loop I'd collect all that data first into local vars prior to starting the loop. On Fri, Jul 21, 2017 at 1:22 AM, Nigel Greenlee via 4D_Tech < [email protected]> wrote: > I suspect the original programmer never intended the functionality to be > running in multiple processes at the same time and used interprocess arrays > to (I think) make it easier to display the data on a form that is in a > different process. Triggers also. I find IP vars in triggers which are generally useless, or worse, on 4D server because the trigger code always runs on the server which has no knowledge of the client IP vars. Same problem with using IP vars as semaphores. It worked way back in the day and doesn't break noticeably when running. > Most code i write now is ‘self contained’ -I attempt to set all values > used in the method is passed in to the code -either as parameters or an > object or a pointer to something so that i end up with something more like > a javascript function. Myreturn:=MyMethod(something;something;something). > Using this style of coding means i am far more likely to get an error if > there is one EVERY TIME rather than a head scratching randomly appearing > one and my code does not rely on the perceived value of a variable. > I find this very true. The time spent writing the method to manage its own variables may be a little more up front but you never have to come back to it unless you are actually changing the method. It also makes it easier to test code. -- Kirk Brooks San Francisco, CA ======================= *The only thing necessary for the triumph of evil is for good men to do nothing.* *- Edmund Burke* ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

