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 2,969 other subscribers

Archive for February 20th, 2014

Enabling HgFlow in SourceTree for Windows: “abort: No module named ConfigParser!” error message with “flow: Flow was already initialized for workspace:”

Posted by jpluimers on 2014/02/20

When you get the below error when adding an HgGlow with SourceTree, then do one of these:

Short error message:

hg flow -y -f init
abort: No module named ConfigParser!

Full error message (the middle line is funny “flow: Flow was already initialized for workspace:”):

hg flow -y -f init
abort: No module named ConfigParser!
flow: Flow was already initialized for workspace:
Completed with errors, see above.

view raw


hosted with ❤ by GitHub

Ultimately, hgflow should fix yinwm / hgflow / issues / #8 – Failing on Windows Binary version, but they haven’t for almost 3 years now.


Posted in Development, DVCS - Distributed Version Control, Mercurial/Hg, Software Development, Source Code Management | Tagged: , | Leave a Comment »

Hidden Features in Delphi related topics (from StackOverflow, until the diamond moderators kill these too)

Posted by jpluimers on 2014/02/20

There are (soon probably “were”) a few very interesting Q&A threads on Stack Overflow in the “Hidden Secrets of” series on Delphi related topics.

I sort of can get (but don’t agree: there is a very good voting system to de-emphasize material that is not useful, but who am I to argue with the minority of “the world is black and white, we just follow the rules” diamondss) that these get closed, but cannot get that very useful material gets deleted for anyone with less than 10-thousand reputation.


@Jeroen & David, I’ve deleted my off-topic comments from here. Could you do the same, please ? I’ve also asked moderators to delete my meta question as it seems the users there are not even humans. Never mind. Stack Overflow is not what it was few years ago as I observe. It’s getting worse. Another piece to this mosaic was running the¬†portuguese version of Stack Overflow¬†ideal for cross posting between the sites.

Posted in Delphi, Development, Software Development | Tagged: | 6 Comments »

How to Use Your Google Maps ‚ÄĒ Offline | Gadget Lab |

Posted by jpluimers on 2014/02/20

Will try this in France this weekend:¬†via:¬†How to Use Your Google Maps ‚ÄĒ Offline | Gadget Lab |

And if it fails, I have CityMaps 2Go Offline Maps and a downloaded map with me as well.

Here‚Äôs how to do it. Read the rest of this entry »

Posted in Android Devices, Google, Nexus 4, Power User | Leave a Comment »

Delphi: the Factory Pattern with virtual Create Constructors (via: What Design Patterns do you implement in common Delphi programming? – Stack Overflow)

Posted by jpluimers on 2014/02/20

Delphi Component Design

Delphi Component Design

From long ago, but still very valid, as I recently had another question like “what design patterns does Delphi use?”.

The Delphi usage of patterns to make the VCL and your applications work is one of the reasons I like the Delphi Component Design: Danny Thorpe so much.
Do not let you scare by the book title: a lot of information in this book is much broader than designing components.
It is about why and how things are done in the RTL and VCL, and which patterns you can use yourself.

Try and git it while you can still get it. It is excellent, but rare to get as it has been out of print for a while.

Only a minority of the Delphi developers knows that every Delphi developer uses a Factory pattern ( 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:

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

For instance the TDirectoryListBox.Create constructor overrides it:

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

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:

  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:

  ClassToCreate: TComponentClass;


procedure SomeMethodInSomeUnit;
  ClassToCreate := TButton;


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

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 blog article 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 :-)

–jeroen Ôú©via:¬†What Design Patterns do you implement in common Delphi programming? – Stack Overflow.

Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Development, Software Development | Tagged: , | 4 Comments »

HTTP protocol requires you to escape spaces (usually with %20 or with +), but web-browsers will do that for you

Posted by jpluimers on 2014/02/20

Since the time that spaces are allowed in path and file names, it has caused confusion.

I personally like the readability of  spaces, but still tend to avoid them as they usually cause more harm than the readability gains.

An interesting thread about spaces in file names is operating systems РWhat technical reasons exist for not using space characters in file names? РSuper User.

In URLs, you there are various kinds of places where spaces can be used. You have to escape as Xah Lee wonders in does HTTP protocol require space be encoded in file path?.

The escaping is part of the URL Encoding, but the escapes depends on the position of the space. In the query part (after the first ?), you can have it escaped by both %20 and plus sign, but in the path part (before the first ? sign), it can only have a %20.

This is explained by bobince in urlencode Рwhen to encode space to plus (+) and when to %20? РStack Overflow.

That escaping basically makes path and file names a lot less readable when passed as a URL. It causes posts like these:

But why can you still use spaces when you type a URL in your web browser, or use it in a href, src or other HTML URL attribute?

Xah Lee rightfully earlier wondered about that in webserver Рspace in url; did browser got smarter or server? РStack Overflow.

Technically, both are not allowed. But web browser manufacturers understand we humans are lazy, and accommodate for that by encoding these when putting them into the HTTP request.

You can type “ bar” in your web browser, and depending on the browser, it gets translated into either one of these:


  • encode spaces in URLs as %20
  • try to avoid spaces in path and filenames



Posted in Development, Encoding, HTML, Software Development, URL Encoding, Web Development | Leave a Comment »

%d bloggers like this: