Sunday, February 21, 2021

Bold big steps

Now when Bold framework are open source we have the possibility to decide in what direction we want. Bold for Sydney is next obvious step. So far Daniel Mauric have done most of the development in Attracs version of Bold so far. Both bugfixes, optimizations and new features. For example our version don't require calls to defaultsubscribe in codederived members. This make code more clean and readable.

But with open source we can cooperate as there are many smart developers  in Bolds community. One example is Yuri that solved the problem with x64. There was a runtime exception that was challenging to fix. Thanks Yuri! I have four ideas here for improvements in Bold. I am not sure if they are doable. I am humble 😊

  1. Threads

With Bold you don't need to write SQL to fetch data from database. Bold generate needed SQL and execute it whenever code needs it. We call it lazy fetch. Disadvantage are that it is slow as SQL is executed one by one in serie. Performance can be improved by prefetch data before it is needed. To call TBoldlist.EnsureObjects is one way. We have even an improvement called spanfetch that Bolds author Jan Norden wrote for us 10 years ago. It try to improve performance by collect access for each class before it is needed in derived members. But the generated SQL is still executed in serie in main thread. So the hourglass is common if there is much data to load. I suggesting have a pool of threads and let them execute SQL instead. It has some advantages.

  • Hourglass is gone and main thread is responsive all the time.
  • Better performance as each SQL is executed in own thread in parallell.
  • Possible to cancel current loading. Just terminate threads that executes SQL.

  1. Replace inc-files 

Code from modelled methods are in inc-files. Class definitions are in a separate inc-file. They are then references from businessclasses.pas. It works well but has some disadvantages for a developer. Most tools assume that code is only in pas-files. An example is Codeinsight in Delphi. It works not so good in inc-files. But also other tools that handle code like analysera have problem.

If you load businessclasses.pas Delphi Sydney be prepared to wait. Much slower than previous releases. I suppose it is because the new language server protocol for Codeinsight. It parse the file when loaded on IDE. Our model has about 460 classes so it try to parse the whole model which of course is slow. If classes can be arranged in ordinary pas-files instead.


  • Smaller files don't need to load all at once so LSP don't need to parse so much when load businessclasses.pas.
  • Tools like Codeinsight and code analyzers works better.

This means code generation needs to be changed to generate code to pas-files instead.

  1. Interfaces

Unittesting with Bold isn't easy. If I want to test class A but that have links to class B that have links to class C. We want to test class A in isolation. Best way to achieve that is to use interfaces instead of direct links to other classes. This means code generation need to be changed to generate interfaces for links.

  1. OCL syntax checks

Visual Studio can syntax check LINQ if I understand it correct in compile time. Could we make similar checks with OCL? BoldHandle already have methods to validate OCL. But only in runtime.

No comments:

Post a Comment