Thursday, May 31, 2012

Namespaces, open source and you

I have to admit - this will be kind of a rant. 8)

These days I am getting really annoyed when people are using XE2 when they are contributing to open source projects that are supposed to work also for XE or lower - no offense.

Huh, why?

Because XE2 just as every Delphi before automatically adds units to the uses clauses which are - you can see what is coming - are different from how they have been before for ages. Instead of having Forms in the uses of the typical VCL application, now we get Vcl.Forms. Or all the units that get added to a form.

So everyone not using XE2 will be unable to compile the awesome code you just wrote if you forgot to manually fix this unless he does it himself!

Maybe some clever people out there familar with IDE plugins figure out a way to restore the old way units are named when using them in a uses clause - which still works given you add the required namespaces to the project options.

Please share your thoughts. :)


  1. Time to upgrade to XE2. While you're at it, maybe it's time to fix stuff like this as well:

    {$ifndef win32}dos,crt,{else}sysutils{$endif}


    Seriously, Delphi automatically adds these namespaces, even to existing code, so you can't really blame developers. Maybe the IDE should add default namespaces to the project settings isntead.

    1. My apologies if it sounded like I am blaming developers for something the IDE does. I am only blaming them for not fixing it manually before commiting but mainly the IDE for being so backwards incompatible.

      Also how is upgrading to XE2 help me write code that works for people that do NOT have XE2? I am not jumping the "screw the people that don't run the newest version" wagon :)

  2. Component or shared-library code used anywhere other than XE2 should NEVER hardcode a "Vcl.Forms" or "System.SysUtils".

    A "de-namespacing" utility would be nice for cleanup, but the problem comes from people.... If they're letting the uses clause stuff slip by unnoticed, who knows what else they're doing?

    On the Jedi JVCL project, I routinely see people check into subversion code that breaks one or more supported version of Delphi. I've probably done it myself, too. Its every developer's responsibility on open source or shared-version projects to NOT BREAK THE BUILD. But when we fail, be kind to us, but tell us. Keep closing the loop.



    1. I agree with you and I am not angry about someone that let it slip through I more am angry about the IDE doing things we manually have to fix.

      While Delphi always claims to be able to still compile Delphi 1 applications with every new version there is something more that makes it hard for its users to be part of an open source team that does not only develop for this newest version. And I am not going into the "if you want bugfixes, buy the new version" thing right now because fortunately with Andy's help I managed to get the knowledge to do that by myself to a certain level.

  3. Possible solution: "Project Options"/"Unit aliases"
    append "vcl.forms=forms"

    1. I would have to do that for every unit, right?

  4. Agree with the sentiment. Disagree with the comments that state this is the IDE's fault somehow - a developer must visually inspect his/her changes before committing anything into the world (that's why we have source version management in the first place.) Commit early and often also ameriolantes this problem.

    1. While I agree that the developer is responsible for his changes (personally made or by some tool he uses) I still blame the Delphi IDE to be very unfriendly when it comes to backwards compatibility.

      We all know tools that changed their file formats during their different versions and many of them still support editing them while preserving their format so other people that don't use the latest version can still open them.

      Since Delphi XE2 supports compiling without full qualified unit names the IDE should do it also.

  5. I try to visually scan my source code when checking in to open source projects that support Delphi XE2 or lower, but my own pubic repository is Delphi XE5 now. I could do the effort there too, but I can spend my energy only once.