Jump to content

Alberto Miola

  • Content Count

  • Joined

  • Last visited

Community Reputation

5 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Alberto Miola

    Automatic documentation generation

    Ok so that's the issue. I have downloaded the project from git and opened it with my laptop in which I have installed 10.3 CE and that's why I cannot find it
  2. Alberto Miola

    Automatic documentation generation

    It seems that there's a program called GenDocCLI does the work but I cannot find it (http://docwiki.embarcadero.com/RADStudio/Rio/en/Running_Documentation_Generation_from_the_Command_Line)
  3. I have a big project that has been well documented and illustrated with UML diagrams. How can I generate the HTML version of the documentation? In this page they say that I have two ways to do it: 2) Where is Generate in the model view page? 1) Where is the option in Tools menu? I have alread done what's written here: http://docwiki.embarcadero.com/RADStudio/Rio/en/XML_Documentation_for_Delphi_Code
  4. Alberto Miola

    Delphi 10.2 TNetHTTPClient vs TRestClient

    If you are using the latest version of the IDE you should also have the latest version (or one of the most recent). If you are going to handle HTTPS, check here! I have never tried TNetHTTPClient so I can't tell nothing about it
  5. Alberto Miola

    Delphi 10.2 TNetHTTPClient vs TRestClient

    I have stopped using Firemonkey in July 2018 (in favor of Flutter which is awesome 😉 ) so what I am going to say could be useless (bugs have been fixed, MAYBE) but these are the issues: There is not a clear way to handle errors with REST components (REST client / request / response) because sometimes they "randomly" raise exceptions When you try to run a non-blocking operation on the background there are so many issues that I cannot write an full list. I had asked a question some time ago for example (https://stackoverflow.com/questions/50437782/delphi-rest-async-request-detect-connection-failure) but no answers. Major problems are: cannot catch exceptions in async requests, connection timeout seems to be broken because it does not actually time out and when you set params for POST requests I cannot remember which problem I had (they were not properly passed due to encoding problems; it was not a problem of mine because with C# I was able to do everything flawlessy) If you try to use the 3 components with live bindings and data sets with the examples given online (or directly downloading the source code) you get N errors of M type I was able to do some stuff with TOAuth1Authenticator using workarounds because it did not work under certain circumstances My solution was the following: TIdHTTP. Indy is very reliable and it allowed me to create my REST service without any problem. I used to handle GET and POST requests with TIdHTTP inside a TTask.Run(); and then with some anonymous function I used to handle the async response. I had spent 3 hours on this which is nothing compared to the 2 days I had spent with REST components (trying to figure out what was wrong). This is my experience and, as I have already said, bugs may have been fixed. I am telling you the problems that I found so you can save your time or see if the components now work properly. If no, you can safely remove them from Delphi and a simple solution is TIdHTTP in a worker thread. Again, if it can be useful to you, I used to write by myself the REST connection handler with TIdHTTP and some good design patterns that helped me were the following: Template Method, Singleton and Decorator. There are many more that can be useful to you, check on Google!
  6. Alberto Miola

    is FGX native still around?

    Yes it is. You can contact Yaroslav Brovin (the owner) via Telegram, the open beta should come in this summer from what I got told
  7. Alberto Miola

    Indy - TIdMultiPartFormDataStream

    I usually use this kind of code: StringStream := TStringStream.Create(Params, TEncoding.UTF8); try Result := FIdHTTP.Post('http://abc.de/my/service/', StringStream); finally StringStream.Free; end; In the above code, I set this property for the FIdHTTP object: //Set the Content-Type FIdHTTP.Request.CustomHeaders.AddValue('Content-Type', 'application/x-www-form-urlencoded'); And here's how the variable Params looks like: Params := 'id=1&name=test'; Server-side, the values can be easily saved with this code: $id = $_POST["id"] //this is '1' $name = $_POST["name"] //this is 'test' Is there a better way? Yes, for sure. I don't know what's the best approach but this is the solution that I usually use to send POST requests via program. It works well
  8. Alberto Miola

    Efficient list box items with Frames

    Ok after some googling I have tried this and it works, but it's under FMX and NOT VCL. procedure TForm2.FormCreate(Sender: TObject); var items: array[0..9] of TListBoxItem; i: integer; frame: TFrame1; begin Randomize; for i := 0 to 10 do begin items[i] := TListBoxItem.Create(Self); items[i].Selectable := false; items[i].Height := 100; frame := TFrame1.Create(Self); frame.Name := 'Test' + IntToStr(i); frame.Parent := items[i]; ListBox1.AddObject(items[i]); end; end; This works fine; I can fill the listbox with many items created as a frame. See the result: http://prntscr.com/ndtuhh Can I do the same with VCL? If no, I will use Firemonkey but I'd prefer using VCL because I think that FMX is pretty broken (I've had bad times with android and ios)
  9. Alberto Miola

    Efficient list box items with Frames

    I have to create a Delphi program and since it's going to run only under Windows, I'm going to use VCL instead of FMX. This is an example of a program that I have made using another library (it's called Qt, it uses C++). Check this picture: https://i.imgur.com/6owIISN.png I'd like to do something like this with VCL. Basically the picture shows that there is a black container and I can put inside it the green rectangle (some objects with an associated "view"). How can this be done with VCL? I have thought that I could create a Frame, put on it the 2 buttons and a label. But then how can I place the frames in the listbox? Do I have to switch to FMX? Thanks
  10. Alberto Miola

    Delphi permutation code complexity

    Those loops are simply not valuable in big O terms because O(infinite) does not exist. f(N) = O(g(N)) if |K*g(n)| => f(n) for K constant and n > n0; this stuff means that the O(something) is a function f that stays below another function g starting from an n0 point. But f and g are both REAL functions and infinite is not in real (R* group) so that's not O(n) and O(infinite) gives the idea but that's mathematically wrong. I don't want to look boring with math things so a reference is here https://en.wikipedia.org/wiki/Big_O_notation and https://en.wikipedia.org/wiki/Taylor_series here (it explains better than me!! 🙂 ) Regarding the loop question, there is a correlation between the "result" of a loop operation and the complexity. It's not the result but it is a point (like 1 in this case) which determines the "starting point" of the asymptotic evaluation. I can't explain well in english this topic but if you have math skill you can understand looking at the definition of O(n) (where the similar applies to sigma(n) and theta(n): https://wikimedia.org/api/rest_v1/media/math/render/svg/847cbaaa1d74b521d199bebdb3b27612e631028b
  11. Alberto Miola

    Hands-On Design Patterns with Delphi

    Very nice I am going to get this book for sure!
  12. Alberto Miola

    Delphi permutation code complexity

    First 2 loops are O(log n) and O(log m). The last loop is clearly O(9) due to the bound but the O(9) is "asymptotically equal" to O(1). Overall you have O(log n + log m + 1) where 1 is constant so only n and m are involved. That complexity is O(log n + log m) but to be correct it would be O(log max{m, n}) where max gives you the biggest value between m or n. Do not say that for loops are O(n) by default, that would be a wrong assumption! Example here: https://stackoverflow.com/questions/10039098/why-is-this-function-loop-olog-n-and-not-on Look this example: var x: double; //x = 1000 maybe while (x > 1) do x := x * 0.3; You are executing this loop many times, let's say n, and so you are taking x * (0.3^n) and you want it to be bigger than something, in this case 1. Now you need to get n from that equation but n is an exponent so you can use logarithms to take the n down like: x * (0.3^n) = 1 -> log(0.3^n) = log(1/x) -> nlog(0.3) = log(1/x) and so on, at the end you'll get an asymptotic O(log n). This is probably not the place to demonstrate what I am saying but if you understand math topics like "limits" and "asymptotes" you can google for this and see that there are methods like substitution, master theorem or trees to get the O(something) notation
  13. I've always had the need to translate my apps in many languages and it's not something that's already integrated in the IDE. Or better, you can localize your VCL projects but there is no support for FMX (and thus, no support for Android/iOS). I have decided to create a component that works with VCL and FMX and can be used to localize your win/android/ios applications. Once the components has been installed in the IDE, it load a json file with all the various translations. This particular json will be created and maintained using the editor I've created. GitHub repo In the repo you can find a quick install guide, a simple tutorial and the source code. I have decided to use this approach because a .json file is easy to maintain and it's basically a text file so the file size is, in general, not a problem at all. Here's an usage example extracted from github: procedure TForm1.FormCreate(Sender: TObject); begin //The 'jsonResourceId' is the Identifier of the .json file that contains the //translated strings. It has to be loaded in the IDE as resource (RCDATA) Language1.setSource('jsonResourceId'); Language1.setLanguage('Default'); end; procedure TForm1.Button1Click(Sender: TObject); begin Language1.setLanguage('it'); //The caption is now 'casa' Label1.Caption := Language1.localize('home'); Language1.setLanguage('fr'); //The caption is now 'maison' Label1.Caption := Language1.localize('home'); end;
  14. Alberto Miola

    MARS now supports Delphi 10.3 Rio :-)

    I have translated
  15. Alberto Miola

    MARS now supports Delphi 10.3 Rio :-)

    Hiandrea, congratulations it's a very nice project! I didn't know about the existance of MARS, I am sure that I'm going to use it next year for a REST project that I have to do at work. I'd like to ask you: is there a component for this library? Or I simply have to import the .pas files?