-
Content Count
1430 -
Joined
-
Last visited
-
Days Won
142
Everything posted by Stefan Glienke
-
Generics: Classes vs Records - Differences in use
Stefan Glienke replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
My number one argument for constraining on class in a generic type argument when possible is that you then can build most of the generic in a non generic layer and just put a small generic layer on top. That makes for less bloat. -
Filter Exception causing debugger errors
Stefan Glienke replied to Stefan Glienke's topic in GExperts
All that I am using which would be mostly 10.1 and 10.4 - I would guess its related to the type of the exception - I usually see this with hardware exceptions such as AV or SO. -
And that is why SRP goes down the drain, cyclomatic complexity increases, potential bugs increase, stuff gets broken - mostly in such swiss army knife classes. And what is complete - that differs for everyone.
-
Topic splitting can easily done by mods. Personally I would welcome if this was done more often so different things can continue being discussed in their own threads.
-
Correct, that's why you close the IDE before you switch the branch
-
If you are referring to switching between different versions of them I can only suggest putting those (yes the binaries, so dcu, dcp, bpl) into vcs - git lfs for example does a fine job.
-
I would never use interposer classes for that but simply run a one time search and replace for all occurences of the third party controls with my own.
-
Interposer classes are only good for components/controls that you already placed on forms because you can keep using them as is while you would need to replace a lets say TButton with TMyAwesomeButton. Where I also like to use them is for extending DUnit as I can use my unit with the TTestCase class then instead of the DUnit one and add functionality - but I would stay away from using it on RTL classes. Funny story: just yesterday we had a sudden compile error from a unit that was not touched in months. A class that was implementing an interface and the compiler complained about missing 2 method implementations. Turned out it was caused by the fact that a junior had added a TAction interposer class into a form unit. That unit was used in the unit which now failed - because those interface methods had TAction in their signature and now they did not match anymore.
-
Take a look at the screenshot you posted yourself...
-
What is wrong with TStringList
Stefan Glienke replied to pyscripter's topic in RTL and Delphi Object Pascal
Loading an entire file into a TStringList is a bad way to begin with tbh yet often the most easy way because there are no nice to use alternatives out of the box. -
GExperts 10.4 dll compiled with Delphi 10.4.1 in Delphi 10.4.0
Stefan Glienke replied to dummzeuch's topic in GExperts
Yep, that's the new virtual method that got added in 10.4.1 which is causing AVs and stuff in plugins compiled with 10.4.0 when you have some form in it inheriting from TDesktopForm or TDockableForm because then the VTables don't match. -
Generics: Classes vs Records - Differences in use
Stefan Glienke replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
(not enough information to give an informed suggestion) - anyhow that was not the question of this topic - as a mod/admin you should not contribute to totally derailing threads 😉 -
Generics: Classes vs Records - Differences in use
Stefan Glienke replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
That would very much depend on the criteria by whom they are looked up, if that criteria changes and how often elements are added/removed don't you think? -
Record Alignement and Delphi 10.4.1
Stefan Glienke replied to Arnaud Bouchez's topic in RTL and Delphi Object Pascal
Reported: https://quality.embarcadero.com/browse/RSP-30890 -
Record Alignement and Delphi 10.4.1
Stefan Glienke replied to Arnaud Bouchez's topic in RTL and Delphi Object Pascal
The offset in the code is correct but the binary layout of the classes are not - here is the dump of the memory layout from the defect: --- TPdfObject --- offset: 4 size: 1 FObjectType: TPdfObjectType offset: 5 size: 4 FObjectNumber: Integer offset: 9 size: 4 FGenerationNumber: Integer offset: 13 size: 1 FSaveAtTheEnd: Boolean --- TPdfStream --- offset: 14 size: 2 ---PADDING--- offset: 16 size: 4 FAttributes: TPdfDictionary offset: 20 size: 4 FSecondaryAttributes: TPdfDictionary offset: 24 size: 1 FDoNotEncrypt: Boolean offset: 25 size: 4 FFilter: AnsiString offset: 29 size: 4 FWriter: TPdfWrite --- TPdfObjectStream --- offset: 31 size: 4 fObjectCount: Integer offset: 35 size: 4 fAddingStream: TPdfWrite offset: 39 size: 4 fObject: :TPdfObjectStream.:2 offset: 43 size: 1 ---PADDING--- size: 48 So the [ebx+$1d] is correct ($1d = 29) - but the starting offset in TPdfObjectStream is wrong. With align Word it looks like this: --- TPdfObject --- offset: 4 size: 1 FObjectType: TPdfObjectType offset: 5 size: 1 ---PADDING--- offset: 6 size: 4 FObjectNumber: Integer offset: 10 size: 4 FGenerationNumber: Integer offset: 14 size: 1 FSaveAtTheEnd: Boolean --- TPdfStream --- offset: 15 size: 1 ---PADDING--- offset: 16 size: 4 FAttributes: TPdfDictionary offset: 20 size: 4 FSecondaryAttributes: TPdfDictionary offset: 24 size: 1 FDoNotEncrypt: Boolean offset: 25 size: 1 ---PADDING--- offset: 26 size: 4 FFilter: AnsiString offset: 30 size: 4 FWriter: TPdfWrite --- TPdfObjectStream --- offset: 34 size: 4 fObjectCount: Integer offset: 38 size: 4 fAddingStream: TPdfWrite offset: 42 size: 4 fObject: :TPdfObjectStream.:2 offset: 46 size: 2 ---PADDING--- size: 52 -
Should Exit be used instead of 'record Exists?' boolean?
Stefan Glienke replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
I would use the Exit version and put the appending new record into its own method. -
Dynamic arrays and copying
Stefan Glienke replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
procedure TestAddRowData(); begin lValues := [ ['one', 1, '1one'], ['two', 2, '2two'], ['three', 3, '3three'] ]; // or SetLength(lValues, 3, 3); lValues[0,0] := 'one'; lValues[0,1] := 1; lValues[0,2] := '1one'; lValues[1,0] := 'two'; lValues[1,1] := 2; lValues[1,2] := '2two'; lValues[2,0] := 'three'; lValues[2,1] := 3; lValues[2,2] := '3three'; end; -
Open array parameters and subranges
Stefan Glienke posted a topic in Tips / Blogs / Tutorials / Videos
How to use open array parameters to handle array subranges: https://delphisorcery.blogspot.com/2020/09/open-array-parameters-and-subranges.html -
Open array parameters and subranges
Stefan Glienke replied to Stefan Glienke's topic in Tips / Blogs / Tutorials / Videos
Ugh, nasty sh*t - can repro in earlier versions than 10.4 as well. The compiler trips over the type inference - need to write MergeSort<T>(...) I would guess it spirals down into some endless loop trying to infer whatever comes back from that tricked Slice call. Updated the blog post - thanks -
https://bitbucket.org/shadow_cs/delphi-leakcheck/src/master/ scroll down to "DUnitX integration"
-
It's just in the comments but anyhow - from line 66 onwards the version is wrong (both 2007 versions were 11, 2009 was 12, 13 was skipped and so on, 10.4 is 27 - hence the 270 suffix on the packages) See: https://delphi.fandom.com/wiki/Delphi_Release_Dates
-
Then you just did not get the issue yet. I am always compiling GExperts myself and I have seen this glitch with 10.4.1. No steps to repro yet though
-
Here is the explanation: http://jedqc.blogspot.com/2006/02/d2006-what-on-earth-are-these-explicit.html
-
Use of Ansistring in Unicode world?
Stefan Glienke replied to Mike Torrettinni's topic in General Help
When David wrote "Andy" he was referring to "Andreas Hausladen" -
Generic circular buffer library released
Stefan Glienke replied to TurboMagic's topic in Algorithms, Data Structures and Class Design
if GetTypeKind(T) = tkClass then PObject(@item)^.Free; RTL still uses DisposeOf (which you also need to if you want to support ARC before 10.4) - look into TObjectList<T>.Notify