特定の汎用トランザクションの永続化メカニズムを管理する境界クラスにイベント ハンドラーがあります。
void MyBoundaryClass::MyEventHandler(...)
{
//retrieve stuff from the UI
//...
//declare and initialize trasaction to persist
SimpleTransaction myTransaction(.../*pass down stuff*/);
//do some other checks
//...
//declare transaction persistor
TransactionPersistor myPersistor(myTransaction, .../*pass down connection to DB and other stuff*/);
//persist transaction
try
{
myPersistor.Persist();
}
catch(...)
{
//handle errors
}
}
SimpleTransaction および TransactionPErsistor オブジェクトをラップするために、ある種の TransactionManager を用意したほうがよいでしょうか?
さらにカプセル化する必要があるかどうかを理解するのに役立つ経験則はありますか?
現時点で私が従う経験則は、「メソッドが大きくなりすぎたら、それについて何かをする」です。境界イベント ハンドラーを扱う場合、手続き型とオブジェクト指向の間の適切なバランスを見つけるのが難しい場合があります。
何か意見はありますか?
乾杯