[Lazarus] Circular references and code quality

Juha Manninen juha.manninen62 at gmail.com
Tue Oct 4 12:01:44 CEST 2011


Hi

There is lots of duplicate code and data definitions between Lazarus
TProject and TLazPackage (and their ancestors).
I tried to improve the situation by creating a common base class for them.
It is not possible because it ends up with a circular reference hell.

Almost 2 years ago I suggested to solve the problem in language syntax
somehow.
  http://lists.freepascal.org/lists/fpc-devel/2010-January/018909.html

The comments always tell to use interfaces and abstract base classes, and
claim that this feature enforces good design.
Bollocks!
This feature enforces BAD design and implementation. Lazarus itself is an
example of it.
Is copy-pasting code between Project and Package a sign of good design. IMO
it is not.
Is the class structure somehow flawed if such problems happen. No it is not.
Such things happen in big, real projects.

For the same reason there are many type-casts in Lazarus core units. A
variable is type-casted from base class to the real class.
Another common solution is to copy all code into one big file. It is not
only a bad thing but it has some limits. You wouldn't want to copy most
Lazarus code into one file for example.
Thus I found it strange that even Lazarus developers claimed they never
encountered such problems. Yet, they have clearly worked hard to avoid
circular references.
It is almost like in a religious sect, nobody dares to admit it was a
mistake to join it.

I read the Bold application has abandoned Delphi native code and moved to
.NET.
The reason was mostly circular reference problems, which I understand with
such object framework tool.

I am not expecting any solution for this now. Even the latest Delphi has not
solved it although it has many other syntax additions.
I just feel strongly that the language will remain a niche, not interesting
for most people, because of this one single problem. Pretty much all other
features are good.
Pity!
I remember already years ago someone told me he used Delphi but it was not
suitable for big projects because of circular reference problems, and he
moved to other languages.
Then I didn't understand how serious the problem is but I learned it later.

If someone still wants to claim that there is absolutely no problem, please
show me how to reuse code between Lazarus Project and Package thus avoiding
the duplicate code, without copying most Lazarus code into one unit.
Then I will believe there is no problem.
Or, explain me why it is a good thing to have all those type-casts in
Lazarus core-units (connecting to Designer etc.).

Sorry for this rant. I like to solve problems but there is no way to solve
this one, except for changing the language. Frustrated now...


Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20111004/82f6daa4/attachment-0002.html>


More information about the Lazarus mailing list