Because there are two uses in delphi

6

Why are there two uses in Delphi units?

One logo under interface and another logo in implementation , what is the purpose?

    
asked by anonymous 18.07.2016 / 21:18

3 answers

5

I believe that the leaner you use the interface, the better.

That's because you'll be able to make more explicit what your interface really needs, and what your code will implement

The classes defined in the uses form a link between the units where they say what they can do. It's basically where they communicate.

In the interface you tell what they can do.

Implementation is where you tell what you need to do.

    
18.07.2016 / 22:17
4

A from above to use system resources and components, such as: System.Classes, System.SysUtils, Vcl.Dialogs, Data.DB etc, etc.

The bottom one is to use resources of another Units such as ufuncoes , uTelaInicial etc etc.

The default is like this, but nothing prevents you from using the bass uses up there or vice versa! But ... not everything is blooming, it can give both compilation errors of execution, so, by default, use the above for System Usage Statements and Components, and below for% uses of your project! / p>

Remembering that declaring above and below the same uses will cause a Duplicate Declaration error!

    
18.07.2016 / 21:47
-3

Organization only. The first one at the beginning is for Delphi libraries that the project needs. The second is for the units of the files of your project, Unit of a form for example.

If you use only the first way, it works the same way.

In summary the first for Units of Delphi the second for their Units.

Okay. I hope I have helped.

    
29.07.2016 / 17:30