Thanks for the many replies.

I mentioned Java because in java it is possible to expose methods/variables ONLY to the other classes in the package. In pascal this is possible too, with the restriction that all those classes must be defined within a single unit. It's that last requirement that I don't like. Would be nicer to bundle multiple units into packages and add some kind of "package wide private" access modifier.

It's tempting for me to use interfaces, but as I'm using inheritance aswell, things get really complex. Imagine that there are classes Y and Z that are derived from X, each having extra methods that should only be called from either A or B. It means that I have to build multiple interface hierarchies. In the end, it just makes things really really complex, only for the sake of keeping some methods hidden.

There are a lot of options for me. I could also use one interface (with it's own inheritance hierarchy) to connect X with module B, and let module A just access X's public methods.

@Mirage: Can you show me an example of aggregation? I've heard that word often, but I don't really know how it solves my problem. Thanks!