[Lazarus] External/out-of-tree LCL widgetset

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Fri Dec 1 20:43:19 CET 2017


On 2017-12-01 13:33, Marcos Douglas B. Santos via Lazarus wrote:
> I believe RAD is the best way to code a GUI....

I'll even disagree with that - somewhat. :)

    http://geldenhuys.co.uk/articles/model-gui-mediator.pdf

With Model-GUI-Mediator (think MVC or MVP design patterns but for modern 
GUI toolkits) you use RAD style to drop components on a form, but you 
DON'T hook into any events or Dataset properties using the form 
designer. Also, you DON'T use data-aware controls.

Instead you use Mediators - a very thin layer of non-gui code (reusable 
and only implemented once) that links widgets and business objects. 
Bi-directional updates occur automatically via the Objserver design 
pattern. MGM was the reason FPC now has Observers built into classes 
like TStringList etc.

The MGM implementation I described in the article is very basic - to get 
the idea across much easier. The MGM implementation inside tiOPF is 
*much* more advanced and improved - requiring *much* less boiler-plate 
coding too.

MGM also allows you to switch your application from LCL to fpGUI to VCL 
in a blink of an eye. The mediators for all these toolkits are already 
written - so nothing new to implement. Switching a form design from 
using a TListView to TStringGrid (or vice-versa) is also a 2 second job.

Creating mediators for new components....For example TChart ora 
DevExpress QuantumGrid is a 5 minute job at most. So suddenly you can 
use any of the free or paid for components - not just db-aware components.

I've used MGM in multiple commercial projects for about 6 years now - it 
works brilliantly. You UI form units are almost empty, and good 
separation of UI, business rules and persistence. Plus I can use OOP and 
real "objects" in my code, not SQL queries and TField instances.

Regards,
   Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp


More information about the Lazarus mailing list