From a while ago: Software design patterns are tools, not goals. Use them as such, and only when you actually need them, not before.
Recommended reading!
via: Oh, hell yeah – Richard Haven – Google+
–jeroen
Posted by jpluimers on 2017/08/09
From a while ago: Software design patterns are tools, not goals. Use them as such, and only when you actually need them, not before.
Recommended reading!
via: Oh, hell yeah – Richard Haven – Google+
–jeroen
Posted in Design Patterns, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2017/08/08
Some really cool YouTube videos below nicely visualise different sorting algorithms are in the playlist below.
They are an extension of https://www.youtube.com/user/AlgoRythmics/videos
It impressed me more than the audible playlist I wrote about in Fun to watch/listen to: Sorting Algorithms (slower, grouped and ordered) – YouTube, likely because the various steps in each sorting algorithm are much more clear.
To me it’s also more entertaining than Sorting | Visual.ly, even though the latter even more clearly show the various operations in a sorting algorithm.
Not all algorithms are covered; https://www.toptal.com/developers/sorting-algorithms/ has many more of them and to my surprise, Heap Sort beats Quick and Quick3 sort on various distributions.
Discussing sorting seems a never ending story…
–jeroen
via: [WayBack] Best description of Bubblesort i’ve ever seen °.° – Fabian S. Biehn – Google+
Posted in Algorithms, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2017/08/08
For my link archive:
git push origin develop:master or $ git push <remote> <local branch name>:<remote branch to push into> can save your asstheirs and ours can be very confusing).–jeroen
Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »
Posted by jpluimers on 2017/08/08
Thanks Stefan Glienke for posting this a while ago:
If you ever wonder why you get no (or incomplete) RTTI from a control that you inherited from a DevExpress one – then look into cxVer.inc where it has the following lines:
{$IFNDEF CXTEST}
{$WEAKLINKRTTI ON}
{$RTTI EXPLICIT METHODS([]) FIELDS([]) PROPERTIES([])}
{$ENDIF}+Martin Wienold was wondering (and so was I at first) why he could not properly resolve a form from the DI container that inherited from TdxRibbonForm despite writing a public method with [Inject] attribute on it but it was never called.
Warning: If you are using DevExpress or any other source code that does this (changing the $RTTI directive) and build these sources together with your application (in contrast to using precompiled dcus or even packages) on a version <XE6 then you might suffer from this issue: [WayBack] #79943: {$ RTTI} flag scope which causes RTTI to disappear even from units that did not have the $RTTI in them.
Source: If you ever wonder why you get no (or incomplete) RTTI from a control that you…
Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2009, Delphi 2010, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, QC, Software Development | Leave a Comment »
Posted by jpluimers on 2017/08/03
Interesting for anybody working on list growth strategies.
In this case with some Delphi background information and in depth coverage of FastMM memory (re)allocation strategies.
[WayBack] Stefan Glienke (of [WayBack] Spring4D fame) needed some help with allocation strategies and observed the difference between:
TList.Grow (and TStringList.Grow) growing like this: 4, 8, 12, 28, 44, 60, 76, 95, 118, 147, 183, 228, 285, 356, 445, 556, 695, 868, 1085TList<T> growing the same way as the .NET List<T>: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024There is this nice [WayBack] Dynamic array – Growth factor – Wikipedia, the free encyclopedia mentioning this table:
Implementation Growth factor (a) Java ArrayList[1] 1.5 (3/2) Python PyListObject[7] 1.125 (9/8) Microsoft Visual C++ 2013[8] 1.5 (3/2) G++ 5.2.0[5] 2 Clang 3.6[5] 2 Facebook folly/FBVector[9] 1.5 (3/2)
[WayBack] Javier Hernández mentioned he doesn’t think exponential is better than n^2.
[WayBack] Eric Grange (of [WayBack] DWS and [WayBack] beginend.net fame) mentions he tends to use 1.5, it is about as good as 2 for small lists, but reduces waste for large ones. He also uses a constant delta to accelerate growth early on, so something like:
n := n + (n div 2) + 8
Since allocation strategies highly depend on the memory allocator as well, I was glad [WayBack] Primož Gabrijelčič (of [WayBack] OnmiThreadLibrary and [WayBack] Smart Mobile Studio fame) elaborated on FastMM:
Stefan Glienke and Primož Gabrijelčič then concluded that:
Source: [WayBack] I was just looking at TList.Grow (and TStringList.Grow) and I realized that the…
Delphi 10.3 Rio makes this configurable in a global way for all threads at the same time (#facepalm! as it is the 1980s Turbo Pascal ExitProc mess all over again): [WayBack] Delphi RTL Improvements in 10.3 Rio via [WayBack] +Marco Cantù is unstoppable. I can’t keep up LOL – Clement Doss – Google+
The SetGrowCollectionFunc is of course not documented in the RTL, only in the [WayBack] What’s New – RAD Studio 10.3 Rio: [WayBack] Search results for “SetGrowCollectionFunc” – RAD Studio 10.3 Rio.
Stefan Glienke commented in that G+ thread:
I recently experimented with different grow factors and while the memory fragmentation can only mitigated for medium and large blocks (where it actually matters imo) it might be beneficial to only grow by 1.5 at that point. But that has yet to be tested.
What I liked so far is the grow strategy that Go uses (2x until 1024, 1.25x after that) – see https://golang.org/src/runtime/slice.go#L115Since you usually set the size upfront if you add many elements at once (well, if you know how many beforehand) the grow strategy only matters in the long run. You want to balance speed (too many realloc might slow things down unnecessarily), memory overhead (if you are overallocating much you risk wasting too much memory) and memory fragmentation (which might happen with a grow factor bigger than the golden ratio)
–jeroen
Posted in .NET, Delphi, Development, Java, Java Platform, Software Development | 7 Comments »
Posted by jpluimers on 2017/08/02
MADExcept and Eurekalog are good products (and there is a JVCL tool as well). If you run your app in the IDE, you get the stack there – but for now, you need to acquire a third party package to get it runtime.I don’t disagree with the wish for a basic call stack tool, that works cross platform, but it would affect third party developers.
Whats the problem? You attach handlers to Exception.GetExceptionStackInfoProc, GetStackInfoStringProc and ` and just call a function that grabs the map or td32 info and generates the callstack – if you don’t want to spend any money for a high quality tool like madExcept (can even use it for free for non commercial use!) then use JclDebug.pas
I edited in some URLs above; the actual info is from: Why Delphi (like other developer environments) natively not included full call stack for every exception… [WayBack] (which is because it would kill even more of the Delphi 3rd party market).
And it taught me about this by madshi (of MADExcept fame):
DebugEngine is a collection of utils related to debug stuff (stack trace, CPU registers snaphot, debug info,…). Basically, I started to write a commercial error log plugin for Delphi, then I noticed that my internal framework got bigger and bigger. So I decided to share it with the community in hope it will be useful.
And there is the JCL ExceptDlg.pas which is quite easy to use: just add it anywhere to your project and the global exception handler will show you a stack trace provided you have a .MAP file or .TDS file (which contains TD32 symbol information) in the same directory as your .EXE.
–jeroen
Example code:
| unit ExceptionHelperUnit; | |
| interface | |
| uses | |
| System.SysUtils; | |
| type | |
| ExceptionHelper = class helper for Exception | |
| public | |
| function Describe: string; | |
| class procedure RaiseNotImplementedException(const aClass: TClass; const aMethodName: string); | |
| class function GetStackTrace: string; | |
| end; | |
| implementation | |
| uses | |
| System.RTLConsts, | |
| System.SysConst; | |
| type | |
| EStackTraceException = class(Exception); // EProgrammerNotFound to make it really clear this is only to be used in very limited places ?? | |
| { ExceptionHelper } | |
| function ExceptionHelper.Describe: string; | |
| var | |
| lStackTrace: string; | |
| begin | |
| Result := inherited ToString(); | |
| if Self is EInOutError then | |
| if Result = System.RTLConsts.SInvalidFileName then | |
| Result := System.SysConst.SInvalidFileName; | |
| if Assigned(StackInfo) then | |
| lStackTrace := StackTrace | |
| else | |
| lStackTrace := 'empty'; | |
| Result := Format('Exception'#13#10'%s at $%p: %s'#13#10'with StackTrace'#13#10'%s', [ClassName, ExceptAddr, Result, lStackTrace]); | |
| end; | |
| class function ExceptionHelper.GetStackTrace: string; | |
| begin | |
| try | |
| Result := 'Get StackTrace via Exception.'; | |
| raise EStackTraceException.Create(Result) at ReturnAddress; | |
| except | |
| on E: EStackTraceException do | |
| Result := E.StackTrace; | |
| end; | |
| end; | |
| class procedure ExceptionHelper.RaiseNotImplementedException(const aClass: TClass; const aMethodName: string); | |
| begin | |
| raise ENotImplemented.CreateFmt('Method %s.%s is not implemented.', [aClass.ClassName, aMethodName]); | |
| end; | |
| end. |
Posted in Debugging, Delphi, Development, MAP Symbol Information, Software Development, TD32/TDS Symbol information | 6 Comments »
Posted by jpluimers on 2017/08/01
Posted in Algorithms, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2017/08/01
A very interesting piece of research, in which I see a very familiar concept of single owners and I new concept of them providing shields for accessing the manually managed memory. I do miss mentions of Anders Hejlsberg, Chuck (Charles) Jazdzewski, or others that lay the foundation of ownership in the [WayBack] TComponent Branch.
Microsoft Research’s manual memory management for .NET: https://www.microsoft.com/en-us/research/wp-content/uploads/2017/07/snowflake-extended.pdf
Interesting concept of manual but safe memory management with exactly one owner of an object at any given moment and shields that prevent an object’s destruction while it’s still in use by other threads.
Source: [WayBack] Christopher Wosinski – Google+
–jeroen
Posted in .NET, Delphi, Development, History, Software Development | Leave a Comment »
Posted by jpluimers on 2017/07/27
Brilliant solution by Asbjørn Heid:
So the solution I came up with is to use the observation that the “array of const” is “array of TVarRec”, and that “array of TVarRec” is passed as as two arguments: a pointer to the data and the length of the array (or rather, the highest index in the array).
Source: Is there a way to convert ‘array of const’ (open array) to TValue? For example,… [WayBack]
–jeroen
Posted in Delphi, Development, Software Development | 1 Comment »
Posted by jpluimers on 2017/07/27
Some links that were useful getting the SMS sending stuff to work.
The documentation is clear on what to do to send/receive SMS:
But it is unclear what USB hardware does work, so here are some links:
You can also do it the other way around:
–jeroen
Posted in Development, Internet, MikroTik, Power User, RouterOS, routers, Scripting, Software Development | Leave a Comment »