Dave Novo
Members-
Content Count
139 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Dave Novo
-
I am a bit new to spring 4D, and am attempting to use ISet<T> as a replacement of the standard set of <type> in Delphi. How do you easily check if an value is in a ISet<T> The use case I have is with an enum. Where TEnumSet = set of enum; In Delphi I would do if myEnumToCheckFor in MySet then ..... I had expected to see a method ISet<T>.Contains<T>:Boolean, or something along those lines, but I don't see anything. It seems like ISet<T> has lots of helpful methods for dealing with other sets, but I cannot find anything to check if an individual item is in the set. Of course, I can create a new set that contains 1 item and use that, but it seems overkill to do presuming Myset:=ISet<some enum> if MySet.InsersetsWith(TCollections.CreateSet([myenumTocheckFor])) do.... am I missing something? note: sorry, I meant to put this in 3rd party, but somehow it ended up here. I cannot seem to find a way to move it to the 3rd party subforum.
-
ISet<T> in spring4D
Dave Novo replied to Dave Novo's topic in Algorithms, Data Structures and Class Design
The reason I was thinking of using ISet is just that Delphi is very verbose: if myEnum in myset then is not so bad but if [enum1,enum2] * myset <> [] then is obscure and if you dont use this syntax frequently you are constantly reminding yourself what the intention was, particularly for more complex set operations. I feel that if mySet.DoesNotContainAny([enum1,enum2]) then is much easier to understand the intention. Not as performant of course. -
ISet<T> in spring4D
Dave Novo replied to Dave Novo's topic in Algorithms, Data Structures and Class Design
Oh thanks. I did not think to go all the way up to enumerable, as I am used to that interface just being for enumeration. I will investigate that further.... -
This may just be a semantic issue. The OP wrote he was "storing" the sum in a label, maybe he meant display. @Anders Melander is correct, data should be stored in variables/fields etc. Of course, if you need to display to the user, some UI control is needed. I have seen too much code where some value was actually stored in a UI control, and the only way to get the current state of that value was to reference the UI control. That is bad.
-
Parallelizing works well if you can break your overall job into multiple independent tasks, and each task can operate independently of the results of the other task. If the tasks depend on each other in any way, it becomes quite complex quite quickly, generally having to introduce locking and communication mechanisms. In the case of RegEx parsing, how would you break your overall search into multiple independent searches. I dont see an easy way to do this. Each match depends on the results of previous matches. I am not saying it cannot be done, someone might have thought of something extremely clever, but its going to be complicated I think.
-
Simulate Multiple Inheritance
Dave Novo replied to Mike Warren's topic in RTL and Delphi Object Pascal
The other thing I would suggest is to have a look at the "implements" keyword. Please consider the code below as pseudocode ICommonFuncs=Interface procedure CommonProc; end TCommonObj=class(TInterfacedObject,ICommonFunc) procedure CommonProc end TapRectangle=class(TRectangle, ICommonFunc) private FCommonObj:ICommonFunc function GetCommonFuncImp:TICommonFunc; public constructor Create; property CommonFuncImpl:ICommonFunc read GetCommonFuncImpl implements ICommonFunc; end constructor TapRectangle.Create; begin FCommonObj:=TCommonObj.Create as ICommonFunc; end The idea here is that the functionality needed for ICommonFunc is actually implemented by a separate object. When you query the ICommonFunc interface from TRectangle you get it from FCommobObj. You can then easily add the same functionality to TCircle in the same way. In general, FCommonObj may need some way to talk back to its owning object to get some specific information. This is helpful if the methods FCommonObj/ICommonFunc follow a template patter where most of the code is in TCommonObj but there is some specific information needed from TRectangle or TCircle. -
I agree with Anders. This question is impossible to answer. An MVP for a "Sale Management and POS software" for one group of products is completely different than from another group of products. i.e. an MVP for selling gumballs is a totally different ballgame from an MVP for a product cars. If deciding an MVP is so simple that you can create one from asking a 1 sentence question to a group of people who know nothing about what you are doing then there would be no need for any domain experts for anything in software development.
-
There is also FastMM5. However, I would suggest looking at your code and figuring out a way to allocate required memory (even if you have to overallocate) and minimize/eliminate heap memory allocations during the threading code.
-
Hello Everyone, I am just wondering if below is simply a bug, or there is some method to the madness. One of the valid windows short date formats is the following So, one would think that if you change windows to the short date format above, and wrote the Delphi code fs:=TFormatSettings.Create; newDate:=StrToDate('05-Apr-17',fs) then you would get a valid date. However, you do not. I checked this on Win7 and Win10, with Delphi Sydney and Seattle. It is hard to believe something this ancient does not work. The fs record has the correct shortMonthNames loaded. There are a few strange issues. 1. The TFormatSettings.ShortDateFormat ends up being dd/MMM/yy because FixDateSeparator replaces the '-' with a '/'. I am not sure this is relevant though, as the TFormatSettings.DateSeparator is still '-' 2. The key thing that fails is TryStrToDate calls ScanDate which exits out because of if not (ScanNumber(S, Pos, N1, L1) and ScanChar(S, Pos, AFormatSettings.DateSeparator) and ScanNumber(S, Pos, N2, L2)) then Exit; i.e. it is trying to find a number, followed by a separator, followed by a number. Even though the current date format specifies that the month portion should be the short name format. Is there another date method I should be using that works more reliably. Or am I doing something wrong?
-
They did a bunch of work recently to autoscale fonts based on the DPI. There is are some new enums to control this TCanvasZoomText=(ztManual, ztNo, ztAuto); TCanvasZoomPen=(zpManual, zpNo, zpAuto);
-
Hello all, If you go to the Delphi help Docking (Delphi) - RAD Studio Code Examples (embarcadero.com) You see if refers to a "docking demo". The general help for the built is docking is woefully inadequate. If you go to RAD Studio Code Examples (embarcadero.com) You find that the code examples are supposed to be at Embarcadero Technologies · GitHub or GitHub - Embarcadero/RADStudio11Demos: Delphi and C++Builder Demos for Embarcadero RAD Studio version 11 I cannot find a docking demo in either location. Has this been removed from the demos? Or am I just going crazy and its really there. Searching the github for the work "dock" and also cloning the repo and searching for "dock" does not turn up any files
-
Hello, Is there an example of how TPropertyChangedEventArgs and associated infrastructure is supposed to be used? I am hoping there is some magic somehow where I can get a notification that a property changed on a class, without having to modify the source of that class to throw an event. Not sure how this would be done, magic code hooks, VMT hijacking or some other craziness. But when I see some of the magic in Spring4D, I can believe that almost anything is possible 🙂
-
IntToStr algorithm (Interesting read)
Dave Novo replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
I never meant to imply that it was unnecessary. In fact, I already applied your excellent code to my own code that was writing out CSV files from large 2D matrices of integers. I was just wondering if there was a wider variety of circumstances that I could also leverage this technique that I was not thinking of. In fact, I also have to write out large matrices of floating point values, so will try to modify the Delphi float conversion routines to work on array of char similar to what you proposed below. TBH though, I have not done much timing. I wonder if the overhead of writing the file to disk dwarfs the time it takes for the conversions. -
IntToStr algorithm (Interesting read)
Dave Novo replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
I am trying to understand when this stack based allocation can practically help, because it seems to me that for the most part, you usually are going to have to do something with this array of char, and inevitably transform it to a string which will do some heap allocation and copy the stack data. The one thing that pops to my head is if saving a large number of integers to a file (as strings of course), when you can write to the file directly from the char buffer allocated on the stack. Then you avoid any heap allocation for a large number of conversions. Are there many other circumstances where you can avoid the eventual conversion to a heap allocated string and reap the benefits of the stack based memory allocation? It seems limited to areas where you are doing large numbers of IntToStr and only need to keep the string value within the local method within the loop. -
Intel Simd-sort library
Dave Novo replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
Correct, we sort arrays of integers and floats all the time. Both double and single. And have to process these millions of values as well. By "process" I mean perform mathematical operations on them. For us the Dew Research library mtxVec has proven invaluable. -
Intel Simd-sort library
Dave Novo replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
We write software that does scientific data analysis. We regularly have to sort arrays of millions of elements of data. But I recognize we are in the minority of developers. -
Is it a problem if I create more threads than host CPU has ?
Dave Novo replied to William23668's topic in General Help
If all threads are fully utilizing the CPU you will more than likely cause slowdowns. The CPU will force one thread to stop, have to push its stack and pop the stack of the new thread, etc etc. As indicated above, for any process where each thread is waiting a lot (not just IO but really anything) you can happily create as many threads as you like (within reason). -
Hello, Does anyone have any idea why my TestInsight could have dissapeared. I do not see it in the View menu, nor can I right click on a project and make it a "test insight" application (ie it just adds the TESTINSIGHT compiler directive". I have uninstalled/reinstalled testinsight 3x already. I am using version 1.2.0.0 that I just installed.
-
I am a newbie to DunitX so this may be a dumb question. If I select some tests to run in the VCL GUI logger, they run fine. When I recompile my app, all the tests are selected again, even though previously I only selected one. Is there a way to have the VCL GUI logger remember my previous selections so I dont have to keep selecting the same things?
-
I figured it out. You have to close the TestRunner Gui properly. Since my test was failing (i.e. crashing) the GuiRunner never closed properly because I stopped running the program after the crash. I had expected that the Guirunner would save the selected tests prior to the test run started.
-
Instead of just using SQL strings, did you think of using some of the existing ORM syntax as a model. There are many examples for Delphi. See TMS Aurelius or Spring4D for examples.
-
Hello, Does anyone have any tips how to make a combo box with a custom drop down editor? For example, I would like to have the dropdown editor be a treeview, and ideally use a virtual string tree as the dropdown editor. Is there a base class in the Delphi hiearchy that is designed for this, or examples of a working one. My google searches have not turned up a nice example.
-
I agree with Darian. We have hired many good Devs in the past with and without Delphi experience. Of course the good Devs with no Delphi experience are already good Devs by any definition i.e. smart, know OOP well, diligent workers. But lets face it, the RTL/VCL is 10s or maybe 100s of thousands of lines of code. You cannot expect a Delphi noob to not take a while to learn even what classes are available and what the methods are. Never mind all the Delphi-isms how to most effectively use them. Never mind how to work around all the bugs in the IDE and all the tricks of the Delphi debugger. Never mind the subtleties of Delphi reference counting that can be different from other libraries. etc. etc. IME it takes at least a few years before a good developer becomes a true good Delphi Developer.
-
Hello, Recently we had to switch to using Project Groups because the delphi compiler ran out of memory, particularly on 64 bit. We created one project that is a console project, that is basically used to create dcus. The a second project that uses those dcus, and compiles other dcus as well. This second project makes the actual EXE. Even though the first project is essentially a "dcu generator" and it is an empty console application (the dpr has a whole bunch of units in the Uses clause, and the following main code) begin try { TODO -oUser -cConsole Main : Insert code here } except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. It still generates an EXE in excess of 100MB. In addition, the time it takes to link and create the EXE is about 2/3 of the time to generate the dcus. However, we dont even need the EXE from the first project. Is there a way to just generate the DCUs but not create an actual EXE?
-
Hello, I am trying to use some unicode math symbols as variables to make code more readable. But I cannot seem to find out how to insert unicode characters into my source code. I am using the consolas (the default) font in the editor. I saw on the internet some blogs that in other apps you enter the code value and then Alt+X, but that brings up model maker code explorer menu. Any tips are appreciated.