<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Calibri, Verdana, Arial, sans-serif; font-size: 12pt;"><div>I agree with what Giuliano has said, but would also encourage Amir to just look at his object hierarchy critically. He does not have to abandon the OOP method just because he got into trouble here.</div><div class="align-left" style="text-align: left;"><i></i><br></div><div>I have run into similar problems when designing my object hierarchies. The solution was found in recognizing my PARTIAL adoption of the OOP method. In other words, I followed OOP up to a certain point, and then saw an easy way to solve some data access problems by short-circuiting the OOP method and making use of the private access afforded by locating several classes in the same unit. But that is, indeed, a shortcut that violates the OOP principles.<br></div><div><br></div><div>One good exercise is to place each class in its own unit. Do the classes now work well together? If not, you have not designed your hierarchy according to proper OOP methodology. <br></div><div><br></div><div class="zmail_extra_hr" style="border-top: 1px solid rgb(204, 204, 204); height: 0px; margin-top: 10px; margin-bottom: 10px; line-height: 0px;"><br></div><div class="zmail_extra" data-zbluepencil-ignore="true"><div><br></div><div id="Zm-_Id_-Sgn1">---- On Sun, 30 Nov 2025 07:49:13 -0500 <b>Giuliano Colla via fpc-pascal <fpc-pascal@lists.freepascal.org></b> wrote ---<br></div><div><br></div><blockquote style="margin: 0px;" id="blockquote_zmail"><div>Hi,<br><br>IMHO your basic problem is that you are trying to use objects in a way <br>which contradict the basic object concept. The basic concept is to <br>expose an interface and hide the implementation. Higher level code <br>should be able to use objects without caring of implementation.<br>Private object members are just private, implementation dependent, and <br>therefore should not be accessible. If they are, you are making your <br>high level code dependent from object implementation, which is wrong.<br>If for some reasons you cannot rearrange your code in such a way as to <br>be coherent with object philosophy, that means that you should not use <br>objects. You're not obliged to.<br>An object is nothing else but a data structure, which includes in <br>addition the procedures to deal with the data.<br>But you may write just data structures and procedures separately, and <br>make whatever you need be accessible form whatever else you need. And if <br>you don't want end users have the same rights, you just use an <br>interface. Your code will be loaded at run time, and end users will only <br>be able to access what the interface exposes.<br>That is the trick used by Lazarus, whose high level objects are <br>implemented in a totally different way depending on the selected widgetset.<br>Just my two cents.<br><br>Giuliano<br><br>Il 28/11/25 22:58, Amir via fpc-pascal ha scritto:<br>> Hi,<br>><br>>  One of the main thing bothering me while developing projects in <br>> Pascal is that my units are getting huge in size! The main reason is <br>> that the nice property that the classes could access each other <br>> private members if they are defined in the same unit motivates/forces <br>> me to define a lot of classes in the same unit. Then, all the <br>> functions/procedures implementation must go into the same unit. I know <br>> I can use inc file but I do not like it! The other option is to use <br>> "Cracker" pattern, in Delphi, which is fine but seems like a hack!<br>><br>>   In C++, the concept of header files vs c++ files is helpful. In <br>> Golang, one could implement the functions for a class in several <br>> files, as long as they are in the same directory (namespace).<br>><br>>   Wondering if there is a solution for this in Object-Pascal?<br>><br>> Best,<br>> Amir<br>><br>><br>> _______________________________________________<br>> fpc-pascal maillist  -  <a target="_blank" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>> <a target="_blank" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br><br>-- <br>Do not do to others as you would have them do to you.They might have different tastes.<br><br>_______________________________________________<br>fpc-pascal maillist  - <a target="_blank" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br><a target="_blank" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br></div></blockquote></div><div><br></div></div><br></body></html>