[Lazarus] Circular references and code quality

Marcos Douglas md at delfire.net
Tue Oct 4 17:54:25 CEST 2011


On Tue, Oct 4, 2011 at 12:12 PM, Alexander Klenin <klenin at gmail.com> wrote:
> On Wed, Oct 5, 2011 at 01:40, Marcos Douglas <md at delfire.net> wrote:
>>> The comments always tell to use interfaces and abstract base classes, and
>>> claim that this feature enforces good design.
>>> Bollocks!
>>
>> I agree with you.
>> I found this example by Nikolai ZHUBR:
>> http://lists.freepascal.org/lists/fpc-devel/2010-January/018942.html
>> I do not think this is better solution. For only one "circular
>> reference" between 2 classes, I have to created 3 files! And if these
>> references grow?!
>
> You misunderstood. Of course you do not have to create 3 files
> to use interfaces -- it is the reverse, interfaces allow you to split
> you code cleanly
> into 3 (or more) files if/when it becomes too large for a single one.

I was talkin about that example... but doesn't matter if you create
one or three files: your have to put all interfaces OR classes in same
file using forward declarations if you want do use dependencies
between these interfaces/classes... I can do this only using classes,
but these was a problem said here, didn't?

If you do not use a single file for these interfaces/classes you
should move up in the hierarchy creating over and over more
abstractions... just because you have a single class A that uses class
B and vice-versa. You do not consider it an unnecessary overhead?

Marcos Douglas




More information about the Lazarus mailing list