brentoboy - 2005-05-10

In my VB programs, I implement error handling in a default way across the entire project.  I end up cutting and pasting and then modifying a lot of code to a lot of functions in order to make my error messages tell me what was going on when I crashed.  Most of this is "mindless" code entry, and prone to the occasional slip that gets overlooked.  It also creates an error handling scheme that I am unlikely to update if I decide I dont like it because it is so tedious.

A "new" programming methodology called aspect oriented programming (AOP) has been created that deals with that sort of mindless code redundancy.  For info lookup AspectJ (a java tool that helps deal with that)

Anyway, to the point:
APe needs to allow for Function Template Definitions where I get to define a Prelude and Postlude to a function that gets evaluated and added just before the code is compiled, but doesnt show up in the source files next time they are edited.

This would allow for housekeeping to be written into a template something like so:

FunctionTemplate Default
_ Try
_ _ Trace "Begin Function:" + <FunctionName>

_ _ <FunctionBody>

_ _ Trace "End Function:" + <FunctionName>
_ OnFail
_ _ Trace "Fail In Function:" + <FunctionName>
_ _ //log a bunch of stuff and pass on the exception
_ End Try
End FunctionTemplate

In this, we define the "Default" function template, so all function templates would use it, unless we selected to use a different template.   We could define a "Special" template that did diffent things, and then create a function that uses the special template like so:

Special Function DoSomething()
// Implementation
End Function

In this way, we can modularize the housekeeping of a function so that it is not part of the maintained area of the code. Allowing us to spend time writing the housekeeping once, and update it as needed without rewriting everything over some minor change.