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 1,380 other followers

Archive for the ‘Event’ Category

Delphi: a pattern for a generic factory, this one for components, but can be uses for anything having a base class like a TThread descendant.

Posted by jpluimers on 2018/05/16

Generics and constraints in Delphi is still a bit of pain.

A while ago, I needed a factory for threads. It was more convoluted than I meant it to be, so I had a short chat with Stefan Glienke.

He came up with an example similar to the one below. I tore it apart so you can on each line see what the compiler dislikes.

This fails, but was kind of how I wanted it to be:

type
   TFactory = record
     class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
   end;

class function Manufacture<T: TBaseClass, constructor>(parameter definitions): T;
begin
  Result := T.Create(parameter values);
end;

Which means I need to update Delphi Constraints in Generics – RAD Studio XE documentation wiki

The factory:

type
  TComponentFactory = class
    class function CreateComponent<T: TComponent>(AOwner: TComponent): T; static;
  end;

class function TComponentFactory.CreateComponent<T>(AOwner: TComponent): T;
var
  ComponentClass: TComponentClass;
  Component: TComponent;
begin
  ComponentClass := T;
  Component := ComponentClass.Create(AOwner); // you can't do `T.Create(AOwner)`
  Result := T(Component); // you can't do `Result := ComponentClass.Create(AOwner);`
end;

The usage:

var
  Component: TButton;
  Owner: TComponent;
begin
  Owner := Application.MainForm;
  Component := TComponentFactory<TButton>.CreateComponent(Owner);
  Component.Parent := Owner;
end;

Full source example is at: After a discussion with Stefan Glienke: a pattern for a factory, this one for components, but can be uses for anything having a base class like a TThread descendant.

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Delphi .dproj file changed or not changed? Normalize it! | The Art of Delphi Programming

Posted by jpluimers on 2018/05/02

Cool tool that integrates into the Delphi IDE: [WayBackDproj changed or not changed? Normalize it! | The Art of Delphi Programming

Via: [WayBack] Introducing DprojNormalizer: http://www.uweraabe.de/Blog/2017/01/18/dproj-changed-or-not-changed/ – Uwe Raabe – Google+

Note there is also RadCLI that requires Python and does it via the command-line:[WayBackjoshkel/RadCli: Command-line utilities for RAD Studio / Delphi / C++Builder

DprojNormalizer supports Delphi XE7 and up.

Updates at [WayBack] Downloads | The Art of Delphi Programming: DprojNormalizer

Note that it requires an elevation to Administrator for installing. If you run Delphi as a normal user, then afterwards you need to register the package yourself, for instance with a batch file like this:

reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\18.0\Known Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer240.bpl" /t REG_SZ /d "Dproj Normalizer" /f
reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Known Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer250.bpl" /t REG_SZ /d "Dproj Normalizer" /f

Adjust your BDS and DllSuffix in the BPL file names using the table at Delphi version info table: C# Builder, Delphi 8 through 10.2 Tokyo and Appbuilder.

If you want to temporarily disable it:

reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\18.0\Disabled Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer240.bpl" /t REG_SZ /d "Dproj Normalizer" /f
reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\19.0\Disabled Packages" /v "C:\Program Files (x86)\DprojNormalizer\DprojNormalizer250.bpl" /t REG_SZ /d "Dproj Normalizer" /f

If you want to re-enable it: remove the values under Disabled Packages.

–jeroen

 

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 1 Comment »

GetPublished – Author Information

Posted by jpluimers on 2018/02/01

One day I must re-publish these papers:

Author Information

ID: 1454
First name: Jeroen W.
Last name: Pluimers
User name:
Biography: Jeroen Pluimers has had a long history in software development ranging from high-level knowledge-based systems to low-level communcation. After discovering his love for teaching, he started one of the first Delphi consulting firms in Europe, and has been speaking at national and international conferences ever since. He presents on Delphi, C#, the Microsoft .NET Platform, and Linux. Jeroen is a Certified Delphi Developer and Borland Certified Instructor. Jeroen’s strength is in getting totally different technologies to work together. He likes to integrate different languages, platforms, frameworks, and databases. As a bug hunter and idea generator, Jeroen has contributed to many products such as Developer Express? Component Development Kit and Borland Delphi. In his free time, Jeroen plays percussion in a world-famous marching band. He also enjoys reading fine books and sampling foreign cuisines.
Image not available

[WayBack] GetPublished – Author Information

From the referencing pages:

Administrating and Configuring Linux for Kylix

Intermediate paper for Delphi programmers starting to use Linux. It explains how to use and integrate Linux and Kylix with Windows and Delphi.�

The Delphi Developer’s Guide to C#

As a Delphi developer, you will find C# easier to learn than you might have thought. Get a head start with this revealing presentation.�

Choosing COM, CORBA or SOAP: What Do they Share and What Sets them Apart

This session describes COM, CORBA and SOAP, indicating what they share, what sets them apart, and how you can choose among them.�

CASE STUDY: ReCruit — Matching and Administration for Recruitment

This session provides a demonstration of ReCruit, including a discussion of its development and deployment process. ReCruit was built using Delphi and InterBase.�

–jeroen

Posted in BorCon, C#, Conferences, Delphi, Development, Event, SOAP/WebServices, Software Development | Leave a Comment »

Record helpers can do wonders for code clarity.

Posted by jpluimers on 2018/01/04

A few people recently discovered the beauty of record helpers:

Record helpers can help any value type (which includes enumerated types) so you can add functions to enumerations.

Class helpers can help class types.

There are no interface helpers and likely won’t be there for a long while.

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Power User, Software Development | 2 Comments »

Delphi: it is better to use ifndef rather than ifdef to keep the IDE working properly…

Posted by jpluimers on 2017/12/28

[WayBackDear diary, today I learned that it is better to use ifndef rather than ifdef if I want the IDE to keep working properly. I had a uses clause with an i… – Stefan Glienke – Google+

I promised to remind myself, so here it is (:

–jeroen

 

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

 
%d bloggers like this: