Question

What is the difference between a declared unit in the interface block and a declared unit in the implementation block?

Was it helpful?

Solution

If the unit is listed in the interface section, it is available both in the interface section and the implementation section. However, if it is listed in the implementation section, it is only available in that section.

Generally speaking, if you only need some unit for the implementation of a unit, then list it in the uses clause of the imlementation section. That way it becomes clear what units the interface of your unit depends upon.

As you know, the interface section of a unit is what other units see. It is simply the 'interface' between your unit and other units. It is like a contract. "This is what I can do, and how you tell me to do it." The implementation section of the unit does all the work promised by the interface section. Here you simply 'implement' the unit; here you put the code of the classes/functions listed in the interface section. The contents of the implementation section is irrelevant details to other units.

This way you can divide your (huge) project into small parts, and it is easy to see how they work together, as a system.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top