The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Archive for January 22nd, 2020

Delphi / Visual Studio build events: xcopy exit code 9009; ensure your PATH indeed includes the Windows directories

Posted by jpluimers on 2020/01/22

If you ever get an exit code 9009 from xcopy like the one below, then try using the full path to xcopy. It should be there, it should not matter, but it does if someone changed your path.

[Exec Error] The command " xcopy ....\Shared\DLL\FastMM\FastMM_FullDebugMode.dll .\Win32\Debug\ /y&& xcopy ....\Shared\DLL\OpenSSL\libeay32.dll .\Win32\Debug\ /y&& xcopy ....\Shared\DLL\OpenSSL\ssleay32.dll .\Win32\Debug\ /y&& xcopy ....\Shared\DLL\gRPC\nghttp2.dll .\Win32\Debug\ /y&& xcopy ....\Shared\DLL\gRPC\sgcWebSockets.dll .\Win32\Debug\ /y" exited with code 9009.

Preliminary solution: replace xcopy    with C:\Windows\System32\xcopy.exe .

Final solution: look with Process Explorer and Process Monitor what the exact environment PATH is. It should include C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;

If it does not, then find out what is changing your path.

Related:

–jeroen

Posted in .NET, Delphi, Development, Software Development | Leave a Comment »

Bloemencorso Bollenstreek vanwege warme winters voortaan een week eerder | NOS

Posted by jpluimers on 2020/01/22

Dit jaar is het corso als vanouds op 25 april. Volgend jaar rijden de praalwagens op 17 april. Afgesproken is wel dat het evenement nooit tijdens Pasen zal worden georganiseerd.

[WayBack] Bloemencorso Bollenstreek vanwege warme winters voortaan een week eerder | NOS

Interferentie met mijn verjaardag (29 april!) gaat dus nooit meer gebeuren (:

–jeroen

Posted in About, Adest Musica, LifeHacker, Personal, Power User | Leave a Comment »

CSS Animation How To Tutorial – Dev Tuts

Posted by jpluimers on 2020/01/22

So as the author of CSS3 Animate It I have a good background in CSS animation. Before CSS3 was released you would have to resort to using JS for animation…

Even after CSS3 got introduced, I’m still not sure I’d use animation: [WayBack] CSS Animation How To Tutorial – Dev Tuts

Via:

–jeroen

Posted in CSS, Development, Software Development, Web Development | Leave a Comment »

The intrinsic factory pattern that every Delphi programmer uses

Posted by jpluimers on 2020/01/22

A blast from the past: my 2009 answer to [WayBackWhat Design Patterns do you implement in common Delphi programming? – Stack Overflow which is still very much relevant today.

TL;DR

Every Delphi programmer uses the factory pattern as it is an intrinsic part of how components at design time work.

So he were go:

Only a minority of the Delphi developers knows that every Delphi developer uses a Factory pattern (delphi.about.com has an example in “regular” Delphi), but then implemented using virtual Create constructors.

So: time to shed some light on that :-)

Virtual constructors are to classes like virtual methods are like object instances.

The whole idea of the factory pattern is that you decouple the logic that determines what kind (in this case “class”) of thing (in this case “object instance”) to create from the actual creation.

It works like this using virtual Create constructors:

TComponent has a virtual Create constructor so, which can be overridden by any descending class:

type
  TComponent = class(TPersistent, ...)
    constructor Create(AOwner: TComponent); virtual;
    ...
  end;

For instance the TDirectoryListBox.Create constructor overrides it:

type
  TDirectoryListBox = class(...)
    constructor Create(AOwner: TComponent); override;
    ...
  end;

You can store a class reference (the class analogy to an object instance reference) in a variable of type ‘class type’. For component classes, there is a predefined type TComponentClass in the Classes unit:

type
  TComponentClass = class of TComponent;

When you have a variable (or parameter) of type TComponentClass, you can do polymorphic construction, which is very very similar to the factory pattern:

var
  ClassToCreate: TComponentClass;

...

procedure SomeMethodInSomeUnit;
begin
  ClassToCreate := TButton;
end;

...

procedure AnotherMethodInAnotherUnit;
var
  CreatedComponent: TComponent;
begin
  CreatedComponent := ClassToCreate.Create(Application);
  ...
end;

The Delphi RTL uses this for instance here:

Result := TComponentClass(FindClass(ReadStr)).Create(nil);

and here:

// create another instance of this kind of grid
SubGrid := TCustomDBGrid(TComponentClass(Self.ClassType).Create(Self));

The first use in the Delphi RTL is how the whole creation process works of forms, datamodules, frames and components that are being read from a DFM file.

The form (datamodule/frame/…) classes actually have a (published) list of components that are on the form (datamodule/frame/…). That list includes for each component the instance name and the class reference. When reading the DFM files, the Delphi RTL then:

  1. finds about the components instance name,
  2. uses that name to find the underlying class reference,
  3. then uses the class reference to dynamically create the correct object

A regular Delphi developer usually never sees that happen, but without it, the whole Delphi RAD experience would not exist.

Allen Bauer (the Chief Scientist at Embarcadero), wrote a short blogarticle about this topic as well. There is also a SO question about where virtual constructors are being used.

Let me know if that was enough light on the virtual Create constructor topic :-)

This resulted in this interesting comment by Kenneth Cochran:

Factory pattern implementations in other languages use ordinary static functions (or class functions for pascalites). As such they are capable of returning null(nil). A Delphi constructor, like the nameless constructors in other languages, will always return an object reference unless you raise an exception. You are free, of course, to use a class function just as easily if the need arises.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »