Re: How to have smaller units

Tomas Hajny via fpc-pascal <[email protected]> Fri, 28 Nov 2025 23:27:22 +0100
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <[email protected]>
On 2025-11-28 22:58, Amir via fpc-pascal wrote:


Hi,

>  One of the main thing bothering me while developing projects in Pascal 
> is that my units are getting huge in size! The main reason is that the 
> nice property that the classes could access each other private members 
> if they are defined in the same unit motivates/forces me to define a 
> lot of classes in the same unit. Then, all the functions/procedures 
> implementation must go into the same unit. I know I can use inc file 
> but I do not like it! The other option is to use "Cracker" pattern, in 
> Delphi, which is fine but seems like a hack!
> 
>   In C++, the concept of header files vs c++ files is helpful. In 
> Golang, one could implement the functions for a class in several files, 
> as long as they are in the same directory (namespace).
> 
>   Wondering if there is a solution for this in Object-Pascal?

What prevents you from declaring the class members as public if you 
want/need to access them from other classes? What prevents you from 
using (public) getters/setters and/or other methods instead of accessing 
the members directly?

Tomas
_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal