[Lazarus] Object free itself?

Lee Jenkins lee at datatrakpos.com
Fri May 16 16:11:34 CEST 2008


Graeme Geldenhuys wrote:
> Lee Jenkins wrote:
>> Well, I'd say yes since I use MGM with tiOPF all the time :)  Actually, I'm 
>> still using them within the Form/View of my MVC implementation, but MGM didn't 
>> seem quite as suited for the job of mediating an entire form whereas MVC did.
> 
> My Forms contain less and less code by the day. To solve the long 
> standing issue of instantiating those mediators, I've played around with 
> the idea of having some design time component I can drop on a form and 
> hooking up the components that need to be used as 'views'.  I started 
> off by using some registry for helper objects so I don't actually have 
> to know which mediator gets used for which object property. It's not 
> 100% complete, but I believe it's heading in the right direction. ;-)

Oooh, that sounds like fun.  I look forward to seeing something when its ready!

Using the MVC approach, one challenge I came up against was replacing the 
"Owner" parameter functionality of the form's constructor.  I find it convenient 
to use this with List Forms where I could have multiple edit forms open which 
represent individual objects in the list form.  This was to ensure that if the 
list form is closed, any edit forms associated with the list form's objects are 
closed automatically as well.

I ended up creating a TMVCControllerManager where I can register controllers 
like this:

gMVControllerMgr.AddController(AController: TMVCController;
   const AKey, AGroup: string);

This allows me to free a controller (and its model and view) or a group 
controllers easily.  I copied the "group" concept from tiVisitorManager...

> As a side note:
> I'm busy writing articles on MGM, MVC and MVP.  For the MVP article I'm 
> trying to coincide it with a MVP implementation for tiOPF. I've finally 
> started understanding the different parts involved in MVP!
> 
> 

I'd very much like to see yours or Michaels' implementation when it finished. 
MVP has quite a few "moving parts" from what I've read.

-- 

Warm Regards,

Lee



More information about the Lazarus mailing list