Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8214287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:24:38+00:00 2026-06-07T11:24:38+00:00

I have a simple style question. In an application that I am writing there

  • 0

I have a simple style question. In an application that I am writing there are several class methods that include a try/catch block as well as function external to the block that depends on the result of the block. For example (in psudo code):

try {
   start_transaction;
   persist_data;
   stop_transaction;
}
catch {
   rollback_transaction;
}
finally {
}

if (transaction_successful)
   send_message;

The only way I can think of for testing if the transaction is successful would be to set a method variable flag in the try catch block and then test it in the if statement. Of course this would work, however I am curious to know what the conventional “wisdom” is with this? Maybe “send_message” should be in the try catch block although this may be unneccessary clutter? I guess this is a fairly straight forward question – just trying to ensure my code is well structured / organised.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:24:40+00:00Added an answer on June 7, 2026 at 11:24 am

    It seems that you need to think a little bit more on the proper layering of your software/increasing of a cohesion for this class/method.
    From the provided example it seems that here you have DAL/business Layer mix (persistense + some business activities), that’s the primary reason you need to react on the result of the transaction in the same method, right after the catch block.

    With proper layering it could look like the following:

    • Persistence fails, you indicating this fact by throwing checked/runtime exception to the calling layer (it’s up to you to decide how to indicate the failure exactly, depdends on your architectural approach),
    • Calling class catches the exception and does error handling – or sends the message in corresponding try block right after the call of the ‘persisting‘ method

    Of course you could set the flag (as you’ve suggested) and use AOP advise to process such situations (esp. in case if ‘send_message’ is auxiliary function).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that is probably very simple, but I cannot find an
I have a simple MFC MDI application, where there is main CFormView, in which
I have a web application that I'm writing (C#, MSSQL) and I need to
I have a verry simple style.less file in my project, and i'm using bootstrap
I have a simple tank wars style game using the allegro open source library.
I have a fairly simple cell in a table with an inline style: <td
i have the following simple code, but it doesn,t work <ul> <li id=one onmouseover=this.style.background-color='white';>
I have problems with creating a simple Group-Box-Control via CreateWindowEx. The font-size/-style of its
My problem is simple, I have the font set in the body style to
i have simple tr an td's coming from database <tr> <td > <td style=

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.