[Lazarus] OOP basics - 2

Juha Manninen juha.manninen at phnet.fi
Thu Apr 15 11:33:13 CEST 2010


> Well, I didn't create any of the code you are referring to.

Ok, I should have checked the facts here. Sorry.

> For the rest: I have a code base of  many millons of lines. Nowhere I
> have encountered the problems you describe. No circular dependencies,
> no need for huge files either. A typical unit contains 4, maybe 5 classes, 
> in rare cases 10. And those classes are always closely bound together, 
> so it simply makes sense to put them in 1 unit.
> 
> As a nice side effect, it makes the uses clauses more simple. If every class
> I ever used was in a separate unit, the uses clauses would simply explode;
> Delphi (or FPC) has trouble enough finding the files it needs. As it is, a 
> typical project takes 15 minutes to compile with delphi on a recent machine. 
> I can't imagine what would happen if I put every class in a separate unit...
> 
> To summarize: All I wanted to say is that
> 
> 1. I don't think that each class should be in it's own unit; If it is
>     beneficial to do so, I will. If not: I don't.
> 
> 2. The structure of my classes has never forced me to solve circular 
references
>     by throwing classes together in 1 unit, or by using strange typecasts.

Huge amounts of code you have!
My experience is that you sometimes end up with big files when you put all 
interdependent classes in it.
Now, the question is also if a big source file is a bad thing or not. I have 
adjusted my way of thinking. The code can be maintained with good tools (like 
Lazarus) even in big files.
A big file is of course intimidating for someone who looks at it for the first 
time, but so are hundreds of small files.


Regards,
Juha




More information about the Lazarus mailing list