hcOPF - ReadingWithChildren

Yes, you should definitely read with your children, but that’s not what this post is about.

Normally when a root object is read in from the object store, all it’s children are also read.  This is not always desirable from a performance standpoint, and it wasn’t an issue until I introduced complete design-time support for bindings.  Now, in order to bind lists, they must be created and added as children to the root object (I use an AfterConstruction override).  Previously, to get deferred loading, you would just create the list and add it as a child, just prior to loading and consuming the list.  While you can still do so, it’s not nearly as convenient, and it means your code won’t be as consistent.  Thus, I have introduced a new property on ThcObjectList called ReadWithChildren.  The default value is True, so the bahaviour will be the same as it always has, but now you can disable it whenever necessary.

In case you’re wondering when you might ever use it, I will provide one such scenario.  I have an Client object with  list of benefits that I have broken out into categories.  Since ThcObjectList doesn’t currently offer very much in terms of list filtering functionality, I have created two lists that I populate when I call a property getter to populate the complete list of benefits.  An added wrinkle is that benefits can expire,  so after I load the main benefit list, I check each benefit to see if it has expired, and if it has I mark it as such, and remove it from the list.  The remaining benefits are added to each separate category list.  Using three lists may seem like overkill, but they share the same objects, and it also makes it easy to change the contents of the grid in which I display them.  I use a single control, and simply change the list the mediator uses at run-time depending on the filter button that is down.  Here is the code fragment I am using:

  //unbind current objects

  //change package list displayed in grid
  GridMediator :=  (obClient.Bindings[1].Mediator as ThcTcxGridMediator);
  if ToHealth then
    GridMediator.ObjectList := Client.HealthBenefits
    GridMediator.ObjectList := Client.FringeBenefits;

  //re-bind to update UI
  obClient.BoundObject := Client;

2 Responses to “hcOPF - ReadingWithChildren”

  1. Andrew Tierney Says:

    Have you tested your framework with Delphi 2010 ?

    And is there a ‘Quick Start’ guide on using your framework, it looks interesting and I’m keen to have a play.


  2. Larry Hengen Says:

    The framework has been tested with D2010 by several developers who use that release. I myself have not used 2010 in some time, so I can’t say whether everything in SVN for that version is 100%. hcOPF is still under active development. There is a GettingStarted.txt file in the Source\Docs folder, and several Demos. If you have any issues feel free to email me.

Leave a Reply