Question: Do you always fully qualify your units in the uses clause(s)?

Question: Do you always fully qualify your units in the uses clause(s)?
i.e.
vcl.Buttons, xml.XMLDoc;
instead of just
Buttons, XMLDoc;

Comments

  1. I recently dropped XE support in my SelectiveDebugging plugin mostly for that reason. The IDE and the IDE tools I use simply don't play well with unqualified unit names. In addition I feel some performance gain as well as a better Code Insight experience when unit names are fully qualified (in addition to explicitly add the units to the project), but that is highly subjective.

    ReplyDelete
  2. Uwe Raabe, I can promise you that it is not subjective. The less of the prefixes that exists in the Project options, the less file lookups are done. I wanted to remove them all, but that screwed up the compiling of the TMS units - who don't use fully qualified names.

    ReplyDelete
  3. The number of lookups for unqualified unit names = <# of prefix substititions> * (<# of unit directories> + <# of reference directories>)

    By reference directory, I mean files that have been attached to a project from any fixed path (which becomes a reference directory)- even if the file is not a compilable item - such as an .html file.

    I suddenly discovered that the IDE was trying paths that were on the network - which naturally brought Code Insight to be slow as molasses.

    ReplyDelete
  4. Come to think of it - it will actually always pose a problem that we use scopeless unit names, since they will always cause a number of combinations (as indicated in the previous comment).

    Would we want to always use a MyLib.UnitName scope - or is it more important to support IDE version that don't support scopes?

    ReplyDelete
  5. Randy Sill Conditional compilation can address that. I do it here, for D2007/XE7.

    ReplyDelete
  6. There are paths in the lookup list which I can't find in the project settings, nor in the library paths. Where to go looking next?

    ReplyDelete
  7. Lars Fosdal registry / programdata ?
    Btw. in what order does the IDE searching for units?
    for example a.) Vcl.Forms; b.) Forms;

    ReplyDelete
  8. Attila Kovacs The extra paths seem to be in the environment settings - but I am not quite certain that I see exactly how they get into the unit searches. Example of paths can be found in the QP issue.

    ReplyDelete
  9. In this answer on StackOverflow I once explained a bit the order of search paths presented to the compiler. I am not sure if this holds true for CodeInsight, too. Perhaps it may help with your analysis.
    stackoverflow.com - Managing very large codebases in Delphi using a Library of Debug and Regular DCUs I built myself

    ReplyDelete
  10. Usually, IFDEF rules the decision Lars Fosdal - based on version and compiler (for example, FPC often must be considered).

    ReplyDelete
  11. I'm considering suggesting introducing an obligatory scope for our units to get away from the extra prefix searches for our team. I've suggested to EMBT that unprefixed filenames are tried first.

    ReplyDelete

Post a Comment