Rollo62 536 Posted January 13, 2022 10 hours ago, Lars Fosdal said: Sliding into off-topic, but I avoid parameters to constructors. ... and there we are again with Uwe's Initialize and my Conf_Setup_ scheme ... I like that approach too, because of the clear separation, but its hard to say where I should use that or better constructor parameters. Maybe the experienced developer has always the right answer, but not me, I usually try and rework my classes many many times, until I find a stable, acceptable final design. Would be great to have some rules in what situations such separation makes sense, you gave already a good hint to that. I like to use the Conf_Setup scheme in combination with the fluent interface, which makes class creation, or class builder, more nice and well readable. begin LMyObj := TMyObj.Create {} .Conf_Setup_Begin {} .Conf_Setup_Color( clBlue ) {} .Conf_Setup_Events( EvOnChange ) ... {} .Conf_Setup_End {} ; end; Most of the time I use class functions in those "Builders", which encapsulates class creation within the class itself. Another step of separation creation and initialization within the "Builder". Share this post Link to post
Attila Kovacs 629 Posted January 13, 2022 What is the problem with conventional coding? Why the ascii art and why not use some properties and a normal try finally? 1 Share this post Link to post
Anders Melander 1783 Posted January 14, 2022 3 hours ago, Attila Kovacs said: What is the problem with conventional coding? It's not "clever". If real problems gets too hard to solve just invent some easy ones. Share this post Link to post