-
Content Count
3323 -
Joined
-
Last visited
-
Days Won
110
Everything posted by Lars Fosdal
-
Question about Delphi class (static) constructor
Lars Fosdal replied to wuwuxin's topic in Algorithms, Data Structures and Class Design
Circular references create a lot of fun. -
So, you want openness to go only in your favor? 😉
-
Open banking is no joke - although I think the interpretation of the term varies with the country you are in. Among other things, open banking allows the banks to hook into each other's APIs so that I, as a client of bank 1 and bank 2, open my page in the UI of bank 1, I can also see the account balances from my account(s) in bank 2. Typically, banking fees are fairly low here and there is no surcharge for this cross bank service.
-
Question about Delphi class (static) constructor
Lars Fosdal replied to wuwuxin's topic in Algorithms, Data Structures and Class Design
A generic class constructor can behave even weirder. https://docwiki.embarcadero.com/RADStudio/Sydney/en/Methods_(Delphi)#Class_Constructors -
FinTech is an abused word.
-
Whenever I write console test app, I am annoyed that I must change from program Project2; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; begin try { TODO -oUser -cConsole Main : Insert code here } except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. to program Project2; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; begin try try except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; finally {$ifdef Debug} Write('Press Enter: '); Readln; {$endif} end; end. which is what I normally want. Is there a way to replace the default code template for a new console project? I would have expected to find it under Tools | Template Libraries - but there is no console project there.
-
Generic event handler for a generic class
Lars Fosdal replied to CoMPi74's topic in Algorithms, Data Structures and Class Design
It's been a while since I tried doing generic based controls, but I think I ran into the same issues. In the end, I changed my approach to using proxy classes that simply hook into the control at runtime and take over its events. -
Generics compiler Error "Incompatible Types"
Lars Fosdal replied to luebbe's topic in Algorithms, Data Structures and Class Design
It is true that if the generic code does not need to touch methods from the interface, the generic type constraint<T:sometype> can be eliminated, but who am I to say what @luebbe will put in his interfaces and code?. -
Generics compiler Error "Incompatible Types"
Lars Fosdal replied to luebbe's topic in Algorithms, Data Structures and Class Design
Would methods exposed by IMyIntf be visible for references to T in the generic code without that constraint? -
Generics compiler Error "Incompatible Types"
Lars Fosdal replied to luebbe's topic in Algorithms, Data Structures and Class Design
It takes a bit of practice - as all things. Me - I struggle with interfaces since I rarely use them. -
Generics compiler Error "Incompatible Types"
Lars Fosdal replied to luebbe's topic in Algorithms, Data Structures and Class Design
The trick to generics is to only specify the desired type on the left side of a declaration and use <T> to "pass it on". Something like this.. type IMyIntf = interface; TMyList<T: IMyIntf> = class; TOnListItemSelected<T:IMyIntf> = procedure(AItem: T) of object; TOnListUpdated<T:IMyIntf> = procedure(AList: TMyList<T>) of object; IMyIntf = interface ['{FCAFF2E8-5F8E-4473-8795-89BD41C89D57}'] end; TMyList<T: IMyIntf> = class FItems: TList<T>; FOnListUpdated: TOnListUpdated<T>; procedure ListUpdated; end; { TMyList<T> } procedure TMyList<T>.ListUpdated; begin if Assigned(FOnListUpdated) then FOnListUpdated(Self); end; -
/facepalm
-
Anybody changing FileVersion directly in dproj file?
Lars Fosdal replied to Mike Torrettinni's topic in General Help
I prefer to use a build server that deals with discovering code changes and performs the versioning. We use Continua CI (which is free for personal use) to automatically start builds after a commit to GitHub, and FinalBuilder which deals with the finer details of configuring projects. Continua can assign the same version number to any number of projects in the build configuration. -
Generics compiler Error "Incompatible Types"
Lars Fosdal replied to luebbe's topic in Algorithms, Data Structures and Class Design
Added advice for generic lists: If you ever need a polymorph generic element type TMyType<T> as well, base it on a skeleton TMyType which contain the verbs and common props you need. TMyType = class public constructor Create; virtual; abstract; procedure SomeOperation; virtual; abstract; end; TMyType<T> = class(TMyType); public constructor Create; override; procedure SomeOperation; override; end; TMyTypeList<T:TMyType, constructor> = class FItems: TList<T>; procedure AddItem(AItem: T); function GetItem: T; end; -
Generics compiler Error "Incompatible Types"
Lars Fosdal replied to luebbe's topic in Algorithms, Data Structures and Class Design
program Project4Fixed; {$APPTYPE CONSOLE} {$R *.res} uses System.Generics.Collections, System.SysUtils; type IMyIntf = interface ['{FCAFF2E8-5F8E-4473-8795-89BD41C89D57}'] end; TMyList<T:IMyIntf> = class FItems: TList<T>; procedure AddItem(AItem: T); function GetItem: T; end; TMyType = class end; TMyTypeList<T:TMyType> = class FItems: TList<T>; procedure AddItem(AItem: T); function GetItem: T; end; { TMyList<IMyIntf> } procedure TMyList<T>.AddItem(AItem: T); var Value: T; begin FItems.Add(AItem); // E2008 Incompatible Types No more - Compiler happy FItems.Add(Value); // Compiler is happy end; function TMyList<T>.GetItem: T; begin Result := FItems[0]; // E2008 Incompatible Types No more - Compiler happy end; { TMyTypeList<T> } procedure TMyTypeList<T>.AddItem(AItem: T); var Value: T; begin FItems.Add(AItem); // E2008 Incompatible Types No more - Compiler happy FItems.Add(Value); // Compiler is happy end; function TMyTypeList<T>.GetItem: T; begin Result := FItems[0]; // E2008 Incompatible Types No more - Compiler happy end; begin try { TODO -oUser -cConsole Main : Code hier einfügen } except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. -
Anon function with undefined result yields no warning
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Well, I voted now, because I got bit by it. -
Seems pretty much dead and buried online. You are probably looking at a painful refactoring.
-
How to use unit BufferedFileStream & FastCopy?
Lars Fosdal replied to Quarks's topic in General Help
To be fair, one of the three disk drives in my laptop is rotating. I'm oldschool (and very large SSDs are still too expensive). -
imagelist Looking for Icon Fonts support in Delphi for High-DPI and Themed app?
Lars Fosdal replied to Carlo Barazzetta's topic in VCL
Have you checked if your app receives any notification after the installation of the font? A sleep seems so random... what if the system is REALLY busy so that the sleep is too short? -
How to use unit BufferedFileStream & FastCopy?
Lars Fosdal replied to Quarks's topic in General Help
Physical heads are increasingly rare these days. My speculation is that the low level DMA mechanisms in the OS might outperform the higher level file routines - but it is pure speculation. -
/off-topic: My mind boggles at the thought of a table without a primary key...
-
How to use unit BufferedFileStream & FastCopy?
Lars Fosdal replied to Quarks's topic in General Help
A random thought I had - what if you copied from one memory mapped file onto another, with multiple threads? I am not even sure that is possible, and it might be a problem with so large files, due to disk storage fragmentation. Edit: Not sure if it is possible to do memory mapping for a removable USB drive. Perhaps you simply need a faster USB unit 😉 https://www.tripplite.com/products/usb-connectivity-types-standards As for copying across network drive, this is where CopyFileEx really does a lot of low level problem solving for you. -
How to use unit BufferedFileStream & FastCopy?
Lars Fosdal replied to Quarks's topic in General Help
Are you doing local copying or copying across the network? From empirical evidence, it seems to open files with read only, deny none. I've never experienced a sharing violation, and I have multiple concurrent clients that pull down changed .exe files from a central share. -
Why are you extracting the blob with AsString and not AsBlob?
-
AFAIK, the Text field in SQLite has no length limit. Why use a BLOb?