[fpc-devel] Circular references and forward declarations
juha.manninen at phnet.fi
Tue Jan 5 21:28:12 CET 2010
On tiistai, 5. tammikuuta 2010 19:48:39 Horacio Jamilis wrote:
> In my case, my classes are defined in a form unit, so I can not have
> more than 1 class per file (this is a Lazarus project)...
> I know that I should have more divided the visible editing and the class
> itself, and I did, with some tricks, but I continue with the 1 file per
> class implementation.
> so the idea to have 1 big file is not possible ... and if it where, i
> will not like it anyway.
> When I asked for this possibility, I was told to create one big unit
> with abstract classes definitions... that may help me, but never had the
> time to test it...
> I am casting everywhere... It´s ugly and error prone, but is what works.
> So this feature could make my life a lot easier ... but I don´t know how
> to implement it... else I would do it.
That is more about separating user interface from program logic which is a
fundamental problem with RAD (rapid application development) tools. Many
people don't like RAD for that reason.
In practice that problem leads to circular reference problems, too.
You should try to separate user interface from program logic.
Do only strictly UI specific stuff in form class units. Keep program logic in
separate units (or one big separate unit :-)).
Then program logic unit can reference freely the form units, and form units
can reference the logic unit only from implementation section.
Thus, no circular reference.
More information about the fpc-devel