[Lazarus] I ported some components, not sure if I can publish them :-(

Luca Olivetti luca at ventoso.org
Fri May 16 10:11:30 CEST 2008


Graeme Geldenhuys wrote:
> 2008/5/15 Lee Jenkins <lee at datatrakpos.com>:
>> I've never tried this type of thing before, but I have need to have an object
>> free self.
> 
> Not allowed, as far as I know.  The execution point has nowhere to
> return to after the 'inherited Destroy' line and before the 'end' of
> the destructor.
> As another object to destroy it. eg: I use something similar in fpGUI.
> I post a message to the fpgApplication instance and request it to free
> of a modeless form (create for CreateForm()).
> 
> 
>> BTW, I'm trying my hand at creaing an MVC and I need the controller to be able
>> to free itself because it is the object that 1) Creates the View (form) and 2)
>> the Model (object) and mediates between them.
> 
> Out of interest. Have you had a look at MGM (Model-GUI-Mediator) yet?
> I'm using it in our current projects and having great success with it.
> MGM fits in somewhere between MVC and MVP.  I think it ties in much
> better with todays more advanced GUI toolkits. It's also very simple
> to implement. tiOPF contains an implementation using RTTI to automate
> a lot of things, but a much simpler implementation could have been
> used as well.
> 

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.

The problem that I have is that I want to be able to completely rid my forms of 
as much code as possible, but I end up with a lot of MGM mediators that I still 
have to instantiate from within the form's OnShow event.  So now I have:


|--Model = TtiObject/List.  Model/Domain Logic.
    |
   View/Form
    |   |
    |   |----MGM Mediators   Dummy View.
    |
   Controller
    |
    |---(Instantiates Model)
    |---(Creates Form/View)
    |---(Instantiates Mediators between Model & View)
    |---(Hooks up/Handles View Logic/Events like Button clicks)
    |---(Tears everything down when finished)

I just create a TMVCController and it takes care of creating the Model, the 
form/view, hooks up and handles the Form/View's events and now with Mattias' 
excellent advice, handles the form's OnClose event and tears everything down.

I wouldn't call it a pure MVC, but for my purposes it seems to work pretty well.

-- 

Warm Regards,

Lee



More information about the Lazarus mailing list