Jump to content

Lars Fosdal

Administrators
  • Content Count

    3483
  • Joined

  • Last visited

  • Days Won

    114

Everything posted by Lars Fosdal

  1. Lars Fosdal

    Function with 2 return values ?

    Screwdriver - what type? Flat, Philips, Pozidriv, Hex, Torq? 😛
  2. Lars Fosdal

    Function with 2 return values ?

    If you return a class instance, you have explicit memory management to deal with (remember to dispose of the response), unlike records where it is handled implicitly.
  3. Lars Fosdal

    Function with 2 return values ?

    A record can mix types. TArray<Double>, not so much, even if I can stuff integers into a double. It is a risky approach to bet on accessing the correct index of an array, instead of a named value in a record. But - both methods have their use.
  4. Lars Fosdal

    Function with 2 return values ?

    Trouble? 😉 I use a record for returning multiple values. Clarity and type safety is of importance to me.
  5. Lars Fosdal

    Parse Json again, complicated

    That is interesting code. How is the performance?
  6. Lars Fosdal

    SQL problem

    You are welcome. So, SQLite wants to load a lot of data unless you filter? Good to know.
  7. Very low seen from Norwegian salary range perspectives as well.
  8. Lars Fosdal

    My app dies in Server 2019

    This is essential to catch issues in runtime. Running an executable without it is like making a train travel blindfolded. You might get where you are going, but if something unpleasant happens on the way, you have no idea of what actually happened. EurekaLog or MadExcept are the best known solutions for capturing exceptions and stack traces.
  9. Lars Fosdal

    SQL problem

    Did you try going 64-bit?
  10. Lars Fosdal

    SQL problem

    My bad for not reading your example closely enough. The problem is that you are not searching for a substring %G:\Delphi Projects\image32_3.2.2\Examples\Layers101% is a superset that contains values that are NOT in the database. You want to find out if your DB text is contained in your parameter - which is completely different thing. FDQuery1.SQL.add('Select MainDirectory'); FDQuery1.SQL.add('from Files'); FDQuery1.SQL.add('WHERE INSTR(''' + Edit1.Text + ''', MainDirectory) > 0'); The above will return lines where the MainDirectory strings are found as part of the string in Edit1.Text.
  11. Lars Fosdal

    SQL problem

    The example does not exemplify the problem. (Delphi 11.1)
  12. Lars Fosdal

    SQL problem

    Did you try it with a ESCAPE '_' clause?
  13. Lars Fosdal

    SQL problem

    I still think it is the underscore that plays a trick on you? Ref. https://www.sqlitetutorial.net/sqlite-like/ - section "SQLite LIKE with ESCAPE clause"
  14. Lars Fosdal

    SQL problem

    Could there be some sort of escape handling kicking in? Is it necessary to pre-process the text you send as parameter to ensure it is correctly handled by SQLite?
  15. Lars Fosdal

    Huge memory problem

    @limelect You probably should read the SQLite docs in detail. Perhaps there are clues to debugging memory consumption there? Is it a configuration thing?
  16. Lars Fosdal

    Huge memory problem

    Leaks come in many forms. It might not be in the Delphi code. https://www.sqlite.org/malloc.html
  17. Lars Fosdal

    Huge memory problem

    Can it be a leak in the application? I.e. you use a DB resource, but never release it after use?
  18. Lars Fosdal

    Huge memory problem

    FireDac is not a database, but Delphi's DB Driver framework. There is no practical size limit in FireDac itself. The limits would be the limits of the underlying database. What is your actual underlying database? A good allround DB is designed to be on disk and to be manipulated on disk and use memory mostly for indexes and caching. Using a billon row DB that fills terabytes of diskspace, does not necessarily imply a performance problem. There are free DBs you can use - even commercially: Postgresql, MariaDB (Open source MySQL), Firebird, etc. Ideally, you would want to limit what you keep in memory, and instead pull in stuff on demand - but that means a redesign of your application. However, if you need/want to load and keep everything in memory, switching from 32-bit to 64-bit will offer a much larger memory space (but then you have to face the sorry state of the 64-bit debugger).
  19. Lars Fosdal

    [Suggestion] Add a new "Created Date" column to "To Do List"

    I'd use the blame view in git to get those dates. The problem with adding an explicit date in the todo comments, is that the comment text may change, but the date is not updated.
  20. Lars Fosdal

    Getters & Settters??

    @David Heffernan - I write about my own preferences, based on my own code, the libraries I use, and the experiences I've had. I am not trying to recommend a "one right way" to write code, since there are so many considerations depending on the context. Which part of "I prefer" do you consider to be a generally invalid point?
  21. Lars Fosdal

    Getters & Settters??

    Look further back in the thread for constructor overloading. It seems like I didn't understand your "not quite the same thing" comment. Care to elaborate?
  22. Lars Fosdal

    Getters & Settters??

    True. But if I need multiple constructors with different arguments to set up a class before use - is that class overly complicated and should it be broken down into a hierarchy?
  23. Lars Fosdal

    Getters & Settters??

    @David Heffernan - I rarely make classes that have so few fields that they are passed in the constructor. Most of my instance data are retrieved from database tables, and each class knows what fields to retrieve (or store). The generic container instantiates the class, the instances fill themselves from the db query. I also have polymorphic classes where each element requires different initializations, which firstly are done by default initializations in the class create, and then secondarily from attributes before the declaration of the class instance reference field. I use this mechanism to build grids in code - and not in design mode. Again, the inits and attributes are the defaults. Overrides are then applied from stored settings.
  24. Lars Fosdal

    Getters & Settters??

    I prefer my constructors without arguments. More abstract / generics friendly. Ref. an earlier comment - I am not so fond of the (ab)use of overload either. It is great for dealing with type translation methods - but multiple overloaded constructors could be very confusing before LSP and inline documentation actually became helpful again. As for number of arguments to a method - as many as it takes, but more than five is pretty rare.
  25. Lars Fosdal

    Getters & Settters??

    ... appear to be nice at first glance, but they tend to be confusing. I'd recommend unique names for each constructor instead.
×