-
Content Count
3319 -
Joined
-
Last visited
-
Days Won
110
Everything posted by Lars Fosdal
-
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
Can you offer an example? -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
I am trying to improve my tendency to spin off a discussion in a thread focused on something else, so here we are. To reiterate, my preference for classes over records with regards to generics, is that read-only generics for records works perfectly for its use, but when you need to update the content in the record, it becomes a very different exercise. You either need to have structure specific methods to change the record field values, or you must copy the entire record, modify it, and the copy it back. The first option wreaks havoc on reuse, and the second option can become a performance bottleneck if the record is large. Even more so, if the record is multidimensional, containing records with arrays of records. The same kind of change in a multidimensional class, is trivial in comparison. @David Heffernan - hence my "the amount of reuse" argument. -
Should Exit be used instead of 'record Exists?' boolean?
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Moved my digressions to -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
"the amount of reuse" was my point. -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
We also know that the two need to be handled differently when it comes to changing their contents. -
I splitted this thread off this
-
What is wrong with TStringList
Lars Fosdal replied to pyscripter's topic in RTL and Delphi Object Pascal
Splitted off the Interposer discussion. -
If I did the my own component approach - I would need multiple versions of the design time components to deal with the different methods of feeding data to the controls, and every time I upgraded TMS, or made a change to the wrapper, I would have to rebuild them. Since the wrapper code is continuously evolving - switching between Live, Pilot and Trunk would be very cumbersome if I had to swap the components used as well. Since the data side of the wrapper is not linked to visual code and the events are connected to the wrapper and not the component, it is easy to write non-visual test code that can simulate UI events. Custom components are an option, but. I personally prefer the wrapper approach.
-
We use interposers or wrapper classes to populate third party components such as the grid, list and combo controls from TMS. It started with us having hundreds of grids, and to get a normalized look, it was better to use a wrapper class to set them up, than to manually configure each class in each form. This class eventually evolved into several wrappers, most of them being data-aware so that we had unified ways of populating a grid, list or combo - straight from SQL, from object lists, or direct fill from "hard code", as well as handling selection events, etc. Another benefit is that if TMS should happen to make changes or add features - we only need to deal with it in the wrappers.
-
Non Delimited string parsing (registry entries)
Lars Fosdal replied to RTollison's topic in General Help
https://larsfosdal.blog/2019/08/06/generic-command-line-parser-for-delphi-10-3-x/ Also, this thread contains numerous other parsers. -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
Start a new topic. Give some examples. -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
Another benefit of using generic classes over records is the amount of reuse. -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
True that. -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
I agree. If we consider the current example, what would be your choice? -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
Exactly. Which is why I use objects. -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
TList<^TDataRec>? -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
Which is why I don't use dictionaries with records. It is rare that I load up a dictionary and do not need to change some of the content later. If I was insistent on doing records, I would probably write code that ordered the array by the key and did binary lookup to a pointer to the record. -
Generics: Classes vs Records - Differences in use
Lars Fosdal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
@David Heffernan The last time I tried that, I was changing copies of what I had put into the dictionary. Perhaps I was doing it wrong? -
Should Exit be used instead of 'record Exists?' boolean?
Lars Fosdal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
How many elements in Data ? -
Issues Deploying Firebird DB on Ubuntu 8.04LTS
Lars Fosdal replied to Larry Hengen's topic in Cross-platform
@Larry Hengen - did you change the access rights (chmod) on the db file as well? What are the access rights? -
Delphi 10.4.1 code navigation - Cursor is vanished
Lars Fosdal replied to RonaldK's topic in Delphi IDE and APIs
Have you tested without extra IDE extensions? -
Delphi 10.4.1 code navigation - Cursor is vanished
Lars Fosdal replied to RonaldK's topic in Delphi IDE and APIs
Found a somewhat related case to my issue in QP: https://quality.embarcadero.com/browse/RSP-28514 Added my comments to it. -
Delphi 10.4.1 code navigation - Cursor is vanished
Lars Fosdal replied to RonaldK's topic in Delphi IDE and APIs
See comments #1 Ctrl+Shift+ArrowUp/Down does not work. Seems to be due to typed constant. See comments #2: Broken class completion, seemingly due to same cause as #1. program SydneyCodeNav; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; type TRec = record a: Integer; // procedure Test; // #2 Uncomment line and press Ctrl+Shift+C to complete code end; TMyObject = class const TR:TRec = (a:1); private procedure InternalTest; // #1 Place cursor here, try Ctrl+Shift+ArrowDown does not work public procedure Test; end; TUnrelated = class // procedure Unrelated; // #2 Uncomment line and press Ctrl+Shift+C to complete code end; { TMyObject } procedure TMyObject.InternalTest; begin Writeln('InternalTest'); // #1 Place cursor here, Ctrl+Shift+ArrowDown end; procedure TMyObject.Test; begin Writeln('Test'); // #1 Place cursor here, Ctrl+Shift+ArrowDown does not work InternalTest; // Ctrl-Clicking InternalTest works end; procedure Test; // Chtrl+Shift+ArrowUp/Down works here var o: TMyObject; begin o := TMyObject.Create; // Chtrl+Shift+ArrowUp/Down works here try o.Test; finally o.Free; end; end; begin try try Test; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; finally Write('Press Enter: '); Readln; end; end. -
Delphi 10.4.1 code navigation - Cursor is vanished
Lars Fosdal replied to RonaldK's topic in Delphi IDE and APIs
I haven't seen that specific problem, but I have some units where Ctrl+Shift+Arrow up/down simply refuses to work in 10.4.1 as well as 10.3.3. I need to try to make a minimal example and report it. -
Delphi 10.4.1 code navigation - Cursor is vanished
Lars Fosdal replied to RonaldK's topic in Delphi IDE and APIs
Is this to navigate between interface and implementation for a class method?