-
Content Count
1149 -
Joined
-
Last visited
-
Days Won
106
Everything posted by Dalija Prasnikar
-
There seems to be more general problem with updating Xcode. Just few days ago I spent 6 hours installing Xcode 12.5.1 It managed to finish only after I deleted old Xcode from applications folder and cleared the trash.
-
How to check if an object implements an interface
Dalija Prasnikar replied to shineworld's topic in Algorithms, Data Structures and Class Design
Use Supports function var LTheme: ITheme; begin if Supports(Obj, ITheme, LTheme) then LTheme.UpdateTheme; end; -
RAD Studio 11 Alexandria is now available
Dalija Prasnikar replied to Darian Miller's topic in General Help
We have no idea. New roadmap hasn't been published yet. -
Is Delphi Interface "polymophic"?
Dalija Prasnikar replied to wuwuxin's topic in Algorithms, Data Structures and Class Design
No. Because you need type for as operator. (intf_1 as IMyInterface).C; But you also need to add GUID to your interface declaration because without it it cannot be identified. -
Try changing more settings. At some point they will be persisted. Another option is to import 10.4.2 settings or change problematic options directly in registry, before you start IDE
-
This sounds like same issue: [REGRESSION] Editor Font setting is not persisted. https://quality.embarcadero.com/browse/RSP-34854
-
RAD Studio 11 Alexandria is now available
Dalija Prasnikar replied to Darian Miller's topic in General Help
No, because there are none. -
RAD Studio 11 Alexandria is now available
Dalija Prasnikar replied to Darian Miller's topic in General Help
Borland is dead. -
RAD Studio 11 Alexandria is now available
Dalija Prasnikar replied to Darian Miller's topic in General Help
Africa, Egypt. There was the largest library in ancient world. -
What everyhing else do you put under source control, apart from Delphi projects?
Dalija Prasnikar replied to Mike Torrettinni's topic in General Help
Not really. https://jlericson.com/2021/08/24/git_rewrite_1.html https://jlericson.com/2021/09/06/git_rewrite_2.html -
What everyhing else do you put under source control, apart from Delphi projects?
Dalija Prasnikar replied to Mike Torrettinni's topic in General Help
Yes. Usually in separate repository, but sometimes in the same as the project which is using them. Anything I can lay my hands on... my book manuscripts, documentation, illustrations and images, 3rd party source code, my own source code or all kinds, recipes, to do lists, basically all kinds of documents that can (or cannot) change with time. -
Is there an elegant way in Delphi to prevent instantiating a class?
Dalija Prasnikar replied to wuwuxin's topic in Algorithms, Data Structures and Class Design
Yes, it can. But the problem is not in hiding your constructor. Every class in Delphi descends from base TObject class, whether you explicitly state that in class declaration or not TSingleton = class TSingleton = class(TObject) And TObject has public constructor Create. That means its every descendant and consequently every other class in Delphi has public constructor Create. Since it is public it is accessible and you cannot prevent people using it. So, even if you hide constructor in descendant class, someone can write TSingleton.Create and this will not call your hidden constructor, but TObject default constructor. The only way to hide that TObject constructor is to add public constructor with same name in your class, like in example I posted. But then you again have problem with having publicly accessible constructor and people can instantiate more than single object instance. If that public constructor raises exception, then at least code will fail at runtime showing that this constructor shouldn't be used. -
Is there an elegant way in Delphi to prevent instantiating a class?
Dalija Prasnikar replied to wuwuxin's topic in Algorithms, Data Structures and Class Design
There is another way to prevent instance creation - or at least misuse - having public constructor that raises exception. TSingleton = class private class var FInstance: TSingleton; constructor CreateSingleton; class destructor ClassDestroy; public constructor Create; class function Instance: TSingleton; static; end; class destructor TSingleton.ClassDestroy; begin FInstance.Free; end; constructor TSingleton.Create; begin raise Exception.Create('Singleton instance cannot be directly constructed'); end; constructor TSingleton.CreateSingleton; begin // actual constructor end; class function TSingleton.Instance: TSingleton; begin if not Assigned(FInstance) then FInstance := TSingleton.CreateSingleton; Result := FInstance; end; -
Is there an elegant way in Delphi to prevent instantiating a class?
Dalija Prasnikar replied to wuwuxin's topic in Algorithms, Data Structures and Class Design
You cannot make such singleton in Delphi. Public TObject constructor will be always visible and you cannot hide it, The only way to disable access to the constructor is to define singleton API as interface and have public factory method that returns interface, and then put class implementation inside implementation section of the unit making it inaccessible to the outside world. -
thread-safe ways to call REST APIs in parallel
Dalija Prasnikar replied to David Schwartz's topic in Network, Cloud and Web
Creating separate objects would be my preferred approach, they are not that heavy to have significant impact on performance. ExecuteAsync is .... I have no words for describing it... maybe some people would like it, but for me it is useless addition. If you want to run rest it in the background thread simplest code is to just run the whole thing in background thread and then synchronize only if you need to synchronize some piece of code. With Execute you get clean code under your control where it is obvious what runs where and how you need to handle things, with ExecuteAsync you first need to learn how to use it properly. I would forget about it as it does not offer any advantages. I am glad if it helped to give you some insight, because I was confused about what you are aiming at. You can ask only very specific questions on Stack Overflow. For instance your initial question here would be definitely off topic on Stack Overflow. If you can create some minimal code example something in line what I have posted here as example, then you can aske whether you are doing it correctly and whether it is thread safe. It is also good to point to specific parts of the code you are not sure about. When it comes to thread safety it depends on the actual code and sometimes people don't add enough code. On the other hand adding too much code is also a problem because it is harder to get clear picture id there is plenty of code. For instance, if you need to populate UI, you don't need to show 50+ lines of UI related code. One is enough. The quality of answers also very much depends on the quality of the question. If answering requires a lot of guessing you will less likely get good answers. Few lines of code speak better than words 🙂 Don't describe your code, write it - even if it is just a rough concept. Then build the rest of the explanation on top of that. -
thread-safe ways to call REST APIs in parallel
Dalija Prasnikar replied to David Schwartz's topic in Network, Cloud and Web
I don't understand what is your problem. You asked whether those classes are safe, we answered they are not. Every thread needs to have dedicated object instance for each one - client, request, response. Even if you use ExecuteAsync, you cannot share that instance. So basic example would be for i := 0 to Data.Count-1 do begin RunRest(Data[i]); end; procedure RunRest(const s: string); begin TTask.Run( procedure var Client, Response, Request... begin Client := TRESTClient.Create(s); try Response := TRESTResponse.Create(Client); Request := TRESTRequest.Create(Client); // other rest setup... Request.Execute; // process Response, if needed you can do that in Synchronize call - if you are interacting with GUI then you definitely need to Synchronize here finally Client.Free; end; end); end; -
Konopka VCL Controls not included in GetIt in delphi community latest edition
Dalija Prasnikar replied to ahmed.atayib's topic in VCL
Konopka VCL Controls are not available for Community Edition. You need to have purchased license (see under Subscription) to get them: https://getitnow.embarcadero.com/KonopkaControls-270-6.2.3/ -
How know interface GUID from generic anonymous function using RTTI
Dalija Prasnikar replied to jairgza's topic in Algorithms, Data Structures and Class Design
TFunc is anonymous method, which are backed by interface. So GUID you get from field type is not for ITestA,, but for TFunc<ITestA>. I don't think you can get generic part out from parameterized type. In theory TFunc has Invoke method, so if you could get information on its result type, you would have ITestA. But I couldn't get Invoke information out of RTTI. The real question here is what you are actually trying to do. Your test code is obviously just a test - you already know that TForm1 MyField works with ITestA, so if you can make small test case for your actual use case, maybe there is a way to get information you need. For instance if your form would be generic, you would more easily get what you need because you would have T to work with TForm1<T> = class(TForm) private MyField:TFunc<T>; end; -
thread-safe ways to call REST APIs in parallel
Dalija Prasnikar replied to David Schwartz's topic in Network, Cloud and Web
None of those components are not thread-safe. They can be used in background threads, but each thread needs to have their own instances. Yes, you need separate client objects for each thread, too. If the StringList is not shared and you generating unique file name is coordinated between threads, so there cannot be any overlap, then it is safe to save inside thread. -
10.4.1+ Custom Managed Records usable?
Dalija Prasnikar replied to Darian Miller's topic in RTL and Delphi Object Pascal
Right... I completely misinterpreted what you were saying. I guess it is "I am reading words, but their meaning is not arriving in my brain" day... -
10.4.1+ Custom Managed Records usable?
Dalija Prasnikar replied to Darian Miller's topic in RTL and Delphi Object Pascal
I think it is called ternary because there are three expressions in play. -
upcoming language enhancements?
Dalija Prasnikar replied to David Schwartz's topic in RTL and Delphi Object Pascal
If anyone is interested in upcoming version, there will be a webinar https://register.gotowebinar.com/register/4959183786599768588 -
10.4.1+ Custom Managed Records usable?
Dalija Prasnikar replied to Darian Miller's topic in RTL and Delphi Object Pascal
I always had high hopes that by 10.7 everything will work as intended. Now we will have to wait until Delphi 17. -
10.4.1+ Custom Managed Records usable?
Dalija Prasnikar replied to Darian Miller's topic in RTL and Delphi Object Pascal
I have seen plenty of developers (not only Delphi) jumping on new features and rewriting code for no good reason. It never hurts explicitly stating even the obvious things -
JSON serialization using published properties w/o attributes
Dalija Prasnikar replied to Zoë Peterson's topic in Algorithms, Data Structures and Class Design
I keep asking myself the same question over and over again. Let me know if you find the answer 😕