Normal Topic Subroutine pointers (Read 490 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Subroutine pointers
Feb 13th, 2004 at 6:47pm
Print Post Print Post  
Can someone please clarify the correct use of Subroutines such as the best place to put the subroutine code, should all subroutine code be kept in one element or ??,  is it better to have many small routines as opposed to one large one etc.

Am I correct in saying a subroutine is beneficial to application speed besides the convenience of  not having to cut and paste redundant code.


Thanks for the help
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Subroutine pointers
Reply #1 - Feb 13th, 2004 at 7:36pm
Print Post Print Post  
Subroutines should be used when you have any significant portion of code that appears at least twice. The benefits are huge. First, in code maintenance, anything that needs fixed or altered only need be altered in one place. Too often I have seen broken code appear throughout a program, partially repaired - left broken because not every instance of it was found (or known to exist). It also make for much less total code. That makes the Sesame data engine run faster. Subroutines also reduce the amount of temporary storage the running program will need to use. In line repeating code (not using a subroutine) will run a tiny bit faster in that it doesn't need to setup a stack and move execution to the subroutine. But the tiny performance gain is not worth the unreliability and difficulty of maintaining repeating inline code. The performance gain in many database will be offset by the slowdown due to increased memory usage and communications speed.

If only one event uses a subroutine, put it with that event. If many use it, put it in the Global Code section for that form.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Subroutine pointers
Reply #2 - Feb 13th, 2004 at 8:00pm
Print Post Print Post  
Thank you for the Clarification  Smiley
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged