[fpc-pascal] How to have smaller units

Amir Amir at Aavani.net
Fri Nov 28 22:58:38 CET 2025


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?

Best,
Amir




More information about the fpc-pascal mailing list