Sub Routine

Sub-routines were the first labor-saving devices invented for programmers (DonKnuth, TAOCP Vol 1, p225).

Create a routine when you want to:

Subroutines help you to: See CodeComplete (SteveMcConnell 1993), Section 4

-- KentSchnaith


Snicker. How many of these did we claim were novel contributions of objects?

-- JimCoplien


I guess we're still trying to solve the same problems. The problems (resulting context?) with the sub-routine solution are:

With objects I think we are trying to get the tools (i.e. compiler) to allow us to define the "rules" and help us catch violations of these "rules" earlier in the development cycle.

-- ShalomReich


The most effective referree I have found to catch violators is to identify the pre-conditions of the subroutine or method (and post-conditions, and static conditions) when writing the subroutine, and add ASSERT() statements to catch violations. If this makes the program too slow, then start at the bottom and prove them out, one routine at a time.

Thanks to DesmondDeSouza at IconComputing for teaching me how to do this.

-- KentSchnaith


See CallingConvention JumpSubRoutine ProcedureWithNoArguments


EditText of this page (last edited January 26, 2005) or FindPage with title or text search