Board index » delphi » Where to put 'uses' clauses

Where to put 'uses' clauses

Hallo.

There are at least two points to put the 'uses': Right after the interface  
statement or right after the implementation statement.

What are the differences, are there any ?

        Mls, Kay

--
**********************************
* k...@edition.bonbit.org         *
* gamemas...@edition.bonbit.org  *
* Telefon: 0431/64526            *
**********************************

 

Re:Where to put 'uses' clauses


On 02 Jul 1996 00:00:00 +0000, K...@jocokko.edition.bonbit.org (Kay

Quote
Hayen) wrote:
>There are at least two points to put the 'uses': Right after the interface  
>statement or right after the implementation statement.

>What are the differences, are there any ?

The difference is that when a unit interface changes, that change
propagates to other units. Changes to the implementation section do
not force recompilation of other units.

Whenever possible, I put unit references into the implementation
section's USES statement. I use the interface's USES statement only
when I need the declarations in the interface section. This minimizes
the amount of recompiling needed.
--
Ray Lischner                              li...@tempest-sw.com
Tempest Software, Corvallis, Oregon, USA  http://www.tempest-sw.com

Re:Where to put 'uses' clauses


Quote
K...@jocokko.edition.bonbit.org (Kay Hayen) wrote:
>There are at least two points to put the 'uses': Right after the interface  
>statement or right after the implementation statement.

>What are the differences, are there any ?

Hello Kay,

At least one important - If you place uses in implementation section,
you will not USE it in interface section (oposite statement is false)

Cheers,
PAwel

--
\||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||/
-         Pawel Ksiezyk     ksie...@bull.mimuw.edu.pl        -
-    Institute of Informatics   Warsaw University   Poland   -
/||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\

Re:Where to put 'uses' clauses


Quote
Ray Lischner wrote:

> On 02 Jul 1996 00:00:00 +0000, K...@jocokko.edition.bonbit.org (Kay
> Hayen) wrote:

> >There are at least two points to put the 'uses': Right after the interface
> >statement or right after the implementation statement.

> >What are the differences, are there any ?

> The difference is that when a unit interface changes, that change
> propagates to other units. Changes to the implementation section do
> not force recompilation of other units.

> Whenever possible, I put unit references into the implementation
> section's USES statement. I use the interface's USES statement only
> when I need the declarations in the interface section. This minimizes
> the amount of recompiling needed.
> --
> Ray Lischner                              li...@tempest-sw.com
> Tempest Software, Corvallis, Oregon, USA  http://www.tempest-sw.com

To expand on what Ray said, you must understand what the parts of a unit
are and what they do in order to understand where to put your use
statements. As a rule of thumb, you will probably be better off to put a
use statement that references *your* units in the implementation section
to prevent circuler references. I leave VCL unit uses in the interface
section. Remember, this is just a rule of thumb - you really need to
understand the parts of a unit and what they do to decided where to put
uses. See chapter 11 of the Object Pascal Language Guide Version 2 for
everything you need to know on this subject. BTW, that chapter is only 4
pages.

Hope this helps,
Greg

Re:Where to put 'uses' clauses


Hallo

li...@tempest-sw.com (Ray Lischner)  meinte am 03.07.96
zum Thema "Re: Where to put 'uses' clauses":

Quote
> On 02 Jul 1996 00:00:00 +0000, K...@jocokko.edition.bonbit.org (Kay
> Hayen) wrote:

> >There are at least two points to put the 'uses': Right after the interface
> >statement or right after the implementation statement.

> >What are the differences, are there any ?

> The difference is that when a unit interface changes, that change
> propagates to other units. Changes to the implementation section do
> not force recompilation of other units.

Hm. Yes, that's a difference, but fortunately Delphi is too quick, to make  
it significant.

Quote
> Whenever possible, I put unit references into the implementation
> section's USES statement. I use the interface's USES statement only
> when I need the declarations in the interface section. This minimizes
> the amount of recompiling needed.

Thanks for your advice. I'll switch to this behaviour.

        Mls, Kay

PS: I really like your postings in comp.lang.delphi.* very much. Allways a  
pleasure to read and quite instructive, I read each one. :-)

--
**********************************
* k...@edition.bonbit.org         *
* gamemas...@edition.bonbit.org  *
* Telefon: 0431/64526            *
**********************************

Other Threads