The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

    • RT @nadineswagerman: Iemand mailde me dat een 13-jarig meisje mijn novelle had uitgekozen om te lezen/bespreken op school. Het boek bevat 9… 6 hours ago
    • RT @jilles_com: Afgelopen 10 dagen hebben we door NL gereisd, elke dag een nieuw hotel en op heel veel locaties gegeten. In 60% van de geva… 6 hours ago
    • RT @FTM_nl: Sywert van Lienden plaatste bewust een serie tweets om het ministerie onder druk te zetten om de omstreden mondkapjesdeal met h… 6 hours ago
    • RT @ArmsControlWonk: China just used a rocket to put a space plane in orbit and the space plane glided back to earth. Orbital bombardment i… 7 hours ago
    • RT @shossontwits: O jee. Nu dit weer. 7 hours ago
  • 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,482 other followers

Archive for April 8th, 2021

UUID/GUID as primary keys in databases; generating them from a .NET assembly

Posted by jpluimers on 2021/04/08

Some links for my archive:

–jeroen

Posted in .NET, Database Development, Development, PostgreSQL, Software Development, SQL Server | Leave a Comment »

Tidy First?

Posted by jpluimers on 2021/04/08

Reminder to myself to check out of the Tidy First? book by Kent Beck got out yet.

I discovered he was writing it after reading this tweet:

Like Extreme Programming, which I used before I even know about the term, Tidy First is my natural way of approaching code: step by step tidying small spots, so I get a feel on the why and how of the code. For me, tidying consists of very small refactorings. I am anxious to see what it means for Kent.

Related links:

–jeroen

Read the rest of this entry »

Posted in Uncategorized | Leave a Comment »

Delphi TestInsight: when supporting it, test if it is running at all. Same library has a deferer pattern.

Posted by jpluimers on 2021/04/08

Interesting idea by Cesar Romero (who has some interesting repositories at [WayBack] cesarliws (Cesar Romero) · GitHub and [WayBack] cesarliws — Bitbucket) when using TestInsight for Delphi: first test if TestInsight is running at all: [WayBack] foundation-4-delphi/Foundation.Test.Utils.pas at master · cesarliws/foundation-4-delphi · GitHub.

function IsTestInsightRunning: Boolean;
{$IFDEF TESTINSIGHT}
var
  TestInsightClient: ITestInsightClient;
begin
  TestInsightClient := TTestInsightRestClient.Create;
  TestInsightClient.StartedTesting(0);
  Result := not TestInsightClient.HasError;
end;
{$ELSE}
begin
  Result := False;
end;
{$ENDIF}

procedure RunRegisteredTests;
begin
  ReportMemoryLeaksOnShutdown := True;

{$IFDEF TESTINSIGHT}
  if IsTestInsightRunning then
    TestInsight.DUnit.RunRegisteredTests
  else
{$ENDIF}
    DUnitTestRunner.RunRegisteredTests;
end;

Another interesting bit from the same library is the deferer pattern (which is different from the promise pattern!)  in [WayBack] foundation-4-delphi/Foundation.System.pas at master · cesarliws/foundation-4-delphi · GitHub with the below code examples.

I think a better name might be DeferExecutionToEndOfScopeFor.

procedure ProcessFile (const FileName: string);
var
  File: TFile;
begin
  File: = TFile.Open (FileName);
  Defer (File.Close);
  while not File.EOF
  begin
    // ... process file
  end;
end; // Defer will be executed here [File.Close]

procedure ExecSql (const ConnectionString, Sql: string);
var
  Database: TDatabase;
  Exec: IDeferred;
  Query: TQuery;
begin
  Database: = TDatabase.Create (ConnectionString);
  Exec: = Defer (Database.Free);
  Database.Open;
  Exec.Defer (Database.Close);

  Query: = Database.Query (SQL);
  Exec.Defer (Query.Free);
  Exec.Defer (Query.Close);
  if Query.IsEmpty then
   Exit;

  while not Query.EOF
  begin
    // ... process query
  end;

  Exec.Defer (
    procedure
    begin
      Writeln ('Finished ExecSql');
    end
  );
end; // Defer will be executed here [Writeln, Query.Close, Database.Close, Database.Free]

–jeroen

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

 
%d bloggers like this: