[fpc-pascal] circular reference
Marcos Douglas
md at delfire.net
Sun Mar 6 15:51:08 CET 2011
On Sun, Mar 6, 2011 at 4:37 AM, Mattias Gaertner
<nc-gaertnma at netcologne.de> wrote:
> On Sat, 5 Mar 2011 23:07:45 -0300
> Marcos Douglas <md at delfire.net> wrote:
>
>> If circular reference not is a good practice (even if to use a
>> implementation section) then I have to put all code, that works
>> together, in the same unit, right?
>
> No, only compatibility or your boss can force you to do that.
> You can use hooks and/or OOP inheritance or interfaces to
> split circular references.
How would be hooks? Can you give me an example, please?
To use inheritance or interfaces makes the code more complex, more
code, just because the circular reference, not a problem of bussines
rules.
Imagine the situation:
unit myclassA;
type
TClassA = class
end;
end.
----------
unit myclassB;
type
TClassB = class
end;
end.
To use inheritance, you propose me to create a new unit and use both
units above?
unit myclasses;
uses myclassA, myclassB;
type
TNewClassA = class(TClassA)
private
FClassB: TClassB;
public
property B: TClassB read FClassB;
end;
type
TNewClassB = class(TEntity)
private
FClassA: TClassA;
public
property A: TClassA read FClassA;
end;
end.
>> So, I ask: Is there a limit of characters at an unit?
>
> The hard limit is far beyond the bearable.
> The Mac OS X platform has a 450.000loc unit, but that is auto
> generated.
> Practically a unit with 10MB/200.000loc feels sluggish to
> work with even on a fast computer.
Ok, no limit. =)
Marcos Douglas
More information about the fpc-pascal
mailing list