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 64367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:46:43+00:00 2026-05-10T18:46:43+00:00

I have some event handler on a boundary class that manages a persistence mechanism

  • 0

I have some event handler on a boundary class that manages a persistence mechanism for a given generic transaction:

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   } } 

Would it be better to have some kind of TransactionManager to wrap SimpleTransaction and TransactionPErsistor objects?

Is there any useful rule of thumb to understand if I need a further level of encapsulation?

At the moment the rule of thumb I follow is ‘if the method gets too big – do something about it’. It is hard sometimes to find the right balance between procedural and object oriented when dealing with boundary event handlers.

Any opinion?

Cheers

  • 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. 2026-05-10T18:46:44+00:00Added an answer on May 10, 2026 at 6:46 pm

    Considering that:

    • the concept of encapsulation is about defining a container, and
    • object-oriented design is based on the concept of message passing (invocation of methods)

    I would argue that the API is a good indication about the pertinence of a new high-level encapsulation (I.e. the definition of a new object)

    If the services (i.e the API) offered by this new object are coherent, and are better exposed to the rest of the program when regrouped in one special object, then by all means, use a new object.

    Otherwise, it is probable an overkill.

    Since you expose a public API by creating a new object, the notion of test may be easier to do within that new object (and a few other mock objects), rather than create many legacy objects in order to test those same operations.

    In your case, if you want to test the transaction, you must actually test MyEventHandler of MyBoundaryClass, in order to retrieve data from the UI.

    But if you define a TransactionManager, that gives you the opportunity to lower coupling of different architecture levels (GUI vs. data) present in MyBoundaryClass, and to export data management into a dedicated class.
    Then, you can test data persistence in independent test scenario, focusing especially on limit values, and database failure, and not-nominal conditions, and so on.

    Testing scenario can help you refine the cohesion (great point mentioned by Daok) of your different objects. If your tests are simple and coherent, chances are that your objects have a well-define service boundary.

    Since it can be argued that Coupling and Cohesion are two cornerstones of OO Programming, the cohesion of a new class like TransactionManager can be evaluated in term of the set of actions it will perform.

    Cohesive means that a certain class performs a set of closely related actions. A lack of cohesion, on the other hand, means that a class is performing several unrelated tasks. […] the application software will eventually become unmanageable as more and more behaviors become scattered and end up in wrong places.

    If you regroup behaviors otherwise implemented in several different places into your TransactionManager, it should be fine, provided that its public API represent clear steps of what a transaction involves and not ‘stuff about transaction’ like various utility functions. A name in itself is not enough to judge the cohesiveness of a class. The combination of the name and its public API is needed.

    For instance, one interesting aspect of a TransactionManager would be to completely encapsulate the notion of Transaction, which would :

    • become virtually unkown by the rest f the system, and would lower coupling between the other classes and ‘Transaction’
    • reinforce the cohesiveness of TransactionManager by centering its API around transaction steps (like initTransaction(), persistTransaction(), …), avoiding any getter or setter for any Transaction instance.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You need to have allow_url_fopen set in your server for… May 11, 2026 at 11:01 am
  • added an answer Well, that's kind how RewriteBase works: it blows away all… May 11, 2026 at 11:01 am
  • added an answer The fix appears to be using the onmousedown event instead… May 11, 2026 at 11:01 am

Related Questions

I have some event handler on a boundary class that manages a persistence mechanism
In some VB6 code, I have a handler for a TreeView's Collapse event: Private
I have an intermittent problem with some code that writes to a Windows Event
I have some code that raises PropertyChanged events and I would like to be
I'm not even sure if it's possible but say I have some XML: <source>
I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs).
I have some UI in VB 2005 that looks great in XP Style, but
I have some ASP.NET web services which all share a common helper class they
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I have some classes layed out like this class A { public virtual void

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.