Re: Nested routines
- Posted by ken mortenson <kenneth_john at y??oo.com> May 28, 2008
- 649 views
Jeremy Cowgar wrote: > > Jason Gade wrote: > > > > What is the utility of nested routines? What problems do they solve that > > can't > > be solved by refactoring and simplification? > > > > Have you ever had to repeat a task over and over in a function that takes > multiple > local paramters and is only used within that one function? All the time. > Why make a top-level function putting it at least into the file scope, Because it makes your current function cleaner and easier to maintain. > deal with passing all the parameters to the function Which is another advantage. Thinking of variable as semi-public within a function is a baaaaad idea. > and getting the result when one could create a nested routine? And another advantage. Those results are part of the unit test procedure. divide and conquer folks. It's the human thing to do. Short answer. It reduces the mental strain on the humble programmer.