I absolutely love the Spring4D libraries and have used them for years. But I am realising I have only scratched the surface. So I thought I would post some of my favourite but less well known features.
I was today years old when I discovered the TBuffer type - it’s part of the cryptography code - but it’s immensely useful
Assignable to/from TBytes
ToHexSting method
Load from/save to TStream
ToString method
Access to the underlying memory via Memory property (pointer).
Size property
Bitwise And/Or/Xor operations.
It’s just an incredibly well thought out type. It’s basically what TBytes should have been!
I only discovered it today when I needed to do some hashing - the spring4d crpytography code is pretty neat too, with support for MD5, SHA1,SHA256, SHA384 and SHA512.
The whole of Spring4D is a gem. I too have only scratched the surface (we primarily use the core features in Collections, Services, Container). I haven’t looked at new features or changes for the last couple of years (note to self - to review).
One hidden gem that we use is Spring.SystemUtils.TEnum that provides convenient ways to convert between enums and strings and integers (e.g. persistence).
I love DelphiPraxis but it sucks for notifications - any post into the Google group directly goes to my emails (well when Google does not mess it up and leaves it closed for ages due to a false positive on some malicious content filter)
The same is the case for StackOverflow - once a week or so I check the spring4d tag.
I use RSS - I have a “bot” (at the moment, a service on a Windows machine) that checks feeds, and posts new entries to related channels in my Slack workspace, e.g. #forum-posts for DP and SO, and #qp for Quality Portal
unit U_unique_count;
interface
procedure unique_count_main;
implementation
uses
System.SysUtils, Spring, Spring.Collections, U_Gen_Data;
const
N = 20000;
crlf = #13#10;
function uniq_spring_set : string;
begin
var s := TCollections.CreateSet(data);
exit('Spring Set : ' + s.Count.ToString + crlf);
end;
function uniq_spring_list : string;
begin
var l := TCollections.CreateList(data);
exit('Spring List : ' + l.Distinct.Count.ToString + crlf);
end;
function uniq_spring_sortedlist : string;
begin
var l := TCollections.CreateSortedList(data);
exit('Spring SortedList : ' + l.Distinct.Count.ToString + crlf);
end;
function uniq_spring_enum : string;
begin
exit('Spring Enumerable : ' + TEnumerable.From(data)
.Distinct
.Count
.ToString + crlf);
end;
function uniq_array_int : string;
begin
var last:= -1;
var cnt := 0;
TArray.Sort<integer>(data);
for var i in data do
if i<>last then begin
inc(cnt); last := i;
end;
exit('TArray : ' + cnt.ToString + crlf);
end;
procedure unique_count_main;
begin
generate_uniq_data(N);
writeln(uniq_spring_set);
writeln(uniq_spring_list);
writeln(uniq_spring_sortedlist);
writeln(uniq_spring_enum);
writeln(uniq_array_int);
end;
end.
I missed that there was a call away outside this section (of course there is).
Quite a bit goes on there, there is an interface behind the scenes … so forget my claim here.