Jump to content

Lars Fosdal

Administrators
  • Content Count

    3323
  • Joined

  • Last visited

  • Days Won

    110

Everything posted by Lars Fosdal

  1. To write an expert that helps separate the UI from the logic would be far from trivial. I strive to write code that is testable, something that Steve McConnell's "Code Complete" drilled into me. My logic routines and biz objects are created without a UI, and the UI itself is connected afterwards. I make an effort to isolate the displayed data from the data that is actually used. I.e. a grid only reflects the underlying data, and all work is done on the underlying data and not the data in the grid itself. A checkbox state reflects the underlying state, and a change to the checkbox affects the underlying data - which then again applies any recalculations to states, and suggest a refresh of the display. The benefits: It is easy to write unit tests and integration tests for the biz logic. It is easy to reuse the code, or change the UI. It also simplfies changing the biz.logic as it is inside the "black box" object, and not heavily tied to the UI. If the tests says the object works, and the app doesn't work - the error is in the coupling between the non-visual object(s) and the UI. The drawback: There is a certain degree of data duplication - but the cost of that is quite limited. You can use proxy classes and/or Attributes/RTTI to associate elements between the non-visual and UI elements. Divide and conquer is good - but hard unless applied from the start on.
  2. Lars Fosdal

    UI resource manager design

    http://docwiki.embarcadero.com/RADStudio/Rio/en/TeeChart
  3. Lars Fosdal

    Receiving incoming calls

    Have you setup the required permissions in the Android manifest? From https://developer.android.com/reference/android/telephony/PhoneStateListener#onCallStateChanged String: call phone number. If application does not have READ_CALL_LOG permission or carrier privileges (see TelephonyManager#hasCarrierPrivileges), an empty string will be passed as an argument.
  4. Lars Fosdal

    UI resource manager design

    https://docs.microsoft.com/en-us/windows/win32/perfctrs/using-the-pdh-functions-to-consume-counter-data
  5. Lars Fosdal

    Difference between Pred and -1

    Wow! That fact had eluded me!
  6. Lars Fosdal

    Threading question

    The book gives a reasonably good understanding of threading issues. That understanding would suggest alternate solutions that avoids the pitfalls of messaging.
  7. Lars Fosdal

    Threading question

    A good place to start for writing solid thread code: https://leanpub.com/omnithreadlibrary
  8. Lars Fosdal

    issues with non-Win platforms

    Ref installation: You can safely install without elevating to localadmin.
  9. Lars Fosdal

    issues with non-Win platforms

    If you had TMS libs from before, like the TMS Component Pack, those are purely VCL for Windows. There are currently two alternatives for cross platform: 1. FireMonkey + TMS FMX Components https://www.tmssoftware.com/site/products.asp?t=fm (All Firemonkey supported platforms) 2. CrossVCL https://www.crossvcl.com/ - not compatible with TMS for VCL, afaik. (MacOS and Linux) Disclaimer: I've not used any of these, only the TMS Component Pack for VCL.
  10. Lars Fosdal

    JSON woes

    Using the std TJson class in REST.Json. Probably not considered gold std.
  11. Lars Fosdal

    Do you name your Threads for debugging?

    Yes. I use the thread class name and an instance id.
  12. Lars Fosdal

    Android FMX Game App not working reliably

    Also, monitor your memory consumption in the Windows App. If it is not stable but keeps growing - there is a chance that you have a leak.
  13. Lars Fosdal

    OS Updates

    That is never wrong. Please ignore me 🖖
  14. Lars Fosdal

    OS Updates

    Not sure why one would want to do this in a Delphi app, when the tools are right there in PowerShell. https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-hotfix?view=powershell-7
  15. Lars Fosdal

    Java novice and Delphi firefox

    Firefox? I assume Firemonkey. You are more likely to get help if you are specific with regards to what you want to do.
  16. Lars Fosdal

    Difference between Pred and -1

    I know... My indendation style is unconventional. It works for me, though.
  17. Lars Fosdal

    Difference between Pred and -1

    Scoured our complete source code and found only one occurence each of pred and succ. One was legit. for e := Low(TElementType) to Pred(High(TElementType)) do // i.e. do not include the last enum value in the loop. The other one was a bullshit one - and I was probably the author of both. function AfterFirst(const Match:char; const st:string):String; var index : Word; begin index := pos(Match,st); if index <> 0 then Result := Copy(st, index + 1, succ(Length(st) - index)) else Result := st; end; It's not even consequent.
  18. Lars Fosdal

    Random Access Violation?

    How about using MadExcept or EurekaLog ?
  19. Lars Fosdal

    IPV6 to number

    That said, there is BigInteger from https://github.com/rvelthuis/DelphiBigNumbers
  20. Lars Fosdal

    IPV6 to number

    An IPv6 address is 128 bits. The answer is no. You'd need two UInt64s to hold that.
  21. Lars Fosdal

    Setting a "nullable" property on a .NET object

    But isn't it still a value type? https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types#how-to-identify-a-nullable-value-type
  22. Lars Fosdal

    Setting a "nullable" property on a .NET object

    100% guesswork without any foundation, except name likeness, follows: There is a GetUnderlyingType property in System.RTTI type TRttiEnumerationType - but it is used absolutely nowhere in the RTL. Also, WinAPI.Ole2 contains a VariantChangeType, and WinAPI.ActiveX contains a VariantChangeTypeEx that may be relevant. System.VarUtils contain both. function TRttiEnumerationType.GetUnderlyingType: TRttiType; begin Result := Pool.TypeOrNil(TypeData^.BaseType); end; function TRttiPool.TypeOrNil(Value: PPTypeInfo): TRttiType; begin if Value = nil then Exit(nil); Result := GetType(Value^); end; function TRttiPool.GetType(ATypeInfo: Pointer): TRttiType; begin if ATypeInfo = nil then Exit(nil); Result := TRttiType(ReadObjectPointer(TRttiType, nil, ATypeInfo)); end;
  23. Lars Fosdal

    3 explorer running

    I see. Personally, I rely on the MRU, Quick Access and Libraries functions that are built into the File Explorer. They are sufficient for me.
  24. Lars Fosdal

    Sort of Drop-down menu, that is not

    I am not sure if these are supported in Lazarus, but you could try an ActionMainMenuBar + ActionManager where you only use the top-level menu items. It would handle the hotkeys for you. ActionBarDemo.zip
  25. Lars Fosdal

    3 explorer running

    @limelect What is the nature of the interaction between your app and the file explorer? Would it be better to launch your own explorer with CreateProcessEx? That way, your app would be the owner, and you would know when it closes, and if you need to launch another. In Windows 10, you can control if folder explorer windows should have separate processes by default or not. The default appears to be not, meaning each explorer opened (from f.x. using Win+E) actually is running in the same process. What is your setting? Does changing this setting affect your observable problem?
×