Monday, 20 October 2008

RunBase - classes and Best Practice

There are certain classes which serve as excellent templates. One such class the LedgerExchAdj-class. If only all runbase-classes were as this one. In my opinion its simplicity and readability is top-notch. I've edited the class-specific code so that only the run() template is present, which included that all important error handling, which one might forget



public void run()
{
#OCCRetryCount
;

try
{
ttsbegin;
// Insert code here
ttscommit;
}

catch (Exception::Deadlock)
{
retry;
}

catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}

1 comment:

Anonymous said...

My favorites for template classes are the WMS classes. They seem all to be written to perfection :-)