6
Because there are two uses
in the Units of Delphi ?
Just below interface
and soon another in implementation
, what the purpose?
6
Because there are two uses
in the Units of Delphi ?
Just below interface
and soon another in implementation
, what the purpose?
5
The top to use system resources and components,
such as: System.Classes, System.SysUtils, Vcl.Dialogs, Data.DB
etc, etc..
The bottom serves to use another’s resources Units
as: ufuncoes
, uTelaInicial
etc etc etc.
The pattern is like this, but nothing prevents you from using the bottom uses up there or vice versa! But... not all are flowers, can give both compilation error of execution, so by default, use the top for System Uses Declarations and Components, and the bottom for uses of Units
of your project!
Remembering that declaring the same uses above and below will cause a Duplicate Declaration error!
5
I believe that the leaner the uses in Interface, the better.
This is 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. Basically that’s where they communicate.
On the interface you say what they can do.
The implementation is where you say what you need to do.
Just to complement, I found this link http://stackoverflow.com/questions/10125641/differences-in-uses-clause
-3
Organization only. The first one at the beginning is for Delphi libraries that the project needs. The second is for the files drives of your project, Unit of a form for example.
If you only use the first way it works the same way.
In summary the first for Delphi Units the second for your Units.
Okay. I hope I helped.
Browser other questions tagged delphi
You are not signed in. Login or sign up in order to post.
I disagree somewhat with his statement. Don’t necessarily use it from
interface
is for system resources and components. Until because if I have a simple class, where it is necessary to make aStrToInt
, I won’t need to use theSysUtils
ininterface
. And another, I may have a method where the return is a specific Object, in which case I would have to declare my class in theInterface
to use it– Victor Tadashi
You may disagree with "Thinking"! For, just open a simple project and add components that use system resources such as a Dbgrid or others, the automatic declaration will be in the Interface. And when using Alt+F11 will be added in Implementation, The Default that "Affirmed" is this!
– Junior Moreira
I’m gonna create a
record helper
String, where I will implement 2 methods,SaveToFile
andLoadFromFile
. For this I will useTStringStream
. No need to declareSystem.Classes
andSystem.SysUtils
in Interface– Victor Tadashi