Ticket CS44139
Visible to All Users

Refactor the ObjectSpace class to make it more extensible

created 18 years ago

Further to issue CQ43837 on Plato's recommendation:
Could you refactor ObjectSpace to make it more extensible and, in particular, to allow it to be subclassed so that it can use UOW descendants. Here are a few suggestions

  1. Make SetSession protected - to allow UOW descendants
  2. Wrap all event firing code into dedicated protected virtual On"EventName"(…) methods - best practice
  3. Make CommitChanges virtual (or make it delegate its functionality to a protected virtual method - to allow additional behaviour to be added for example if we need to enhance how exceptions generated during save are handled.
  4. I assume, since you plan to support different orm layers at some point, you might want to create IObjectSpace and split ObjectSpace into abstract ObjectSpaceBase and concrete ObjectSpace (i.e. "ObjectSpaceXPO").
    Many thanks,
    Jascha
Comments (2)

    A few more observations, you would also need to provide protected access to
    objectsToSave
    isNewCache
    or initialise these in a protected constructor that is called by the other protected / public ones.
    OR, continue use of the factory pattern by adding a IUnitOfWorkProvider parameter to ObjectSpace.

    Roman Eremin (DevExpress) 16 years ago

      I believe everything you need is implemented.

      1. There is a virtual CreateUnitOfWork factory method.
      2. Done
      3. Use CustomCommitChanges event (set Handled in eventargs if you handled it) or override DoCommit.
      4. We are not quite there yet.
      5. objectToSave and DropIsNewCache are protected.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.