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

  • SEARCH
  • Home
  • 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 7186847
In Process

The Archive Base Latest Questions

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

I have adopted a technique where I pass existing objects to forms so that

  • 0

I have adopted a technique where I pass existing objects to forms so that they can display the object’s content and allow the user to alter it if necessary. The form is not bound to the object, so when it comes time to act, the form sweeps up the content of its controls and puts them into the object. The object is then validated and any issues reported to the user. If the object is valid, it may be handed back to the caller so the caller can refresh a view/list/etc.

So far, so good. However, if the form’s content, or lack of, creates an invalid object and the user does not correct it, maybe cancelling the form, there’s a chance the form will hand an invalid object back to the caller. This is not good.

Essentially I’m looking for an elegant and efficient way of either leaving the object as it was or rolling back if the user cancels the form/action.

I have considered a range of techniques, each with many pros and cons. I’m keen to consider some other views.

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

    In the past, I have solved this by making a shallow copy of the object when passing it out to your form. Then, when the copy comes back you validate it. If it checks out, you simply overwrite the original object with the copy.

      private static void PassTheObj()
      {
         MethodThatAcceptsObj(realObject.Copy());  
      }
    
      private static void ValidateObj(customObject objCopy)
      {
         if (objCopy.IsValid()) realObject = objCopy;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have a command handler for a ToggleButton that can take multiple
I work for a large company that has adopted sharepoint. I have been tasked
We have recently adopted the specification patterns for validating domain objects and now want
It occurred to me today that although I've adopted and don't infrequently use the
The equals() method (and for that matter, also the compareTo() method) can become a
I have an adopted implementation of a simple (no upgrades or timeouts) ReaderWriterLock for
I have a worker thread that is listening to a TCP socket for incoming
I have written a page here on using arrays as proper objects with their
Let's say, for the sake of argument, that I have 30 asp.net web applications
FYI I have adopted the mediator pattern for my GUI in Swing on Java.

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.