Framework design, initialization and framework usage
Jacob Carlborg
doob at me.com
Mon May 6 18:34:59 UTC 2019
On 2019-05-06 20:03, Robert M. Münch wrote:
> What I want to avoid is that explicit init line in main(). So, the user
> should derive whatever make sense for the app, but main() is never
> touched by the user. main() should initialize the user's app code
> "automatically" and be part of the framework.
I strongly advice against the framework containing the "main" function.
It just going to cause problems. Take a look at vibe.d, that initialize
started with containing the "main" function and the user writing their
code in a "shared static this". That's just ugly and there's no
advantage. This caused problems with testing and various versions
identifiers had to be enabled or disabled to get it to work properly.
Since this is a framework you might want to consider having a tool that
generates a project and outputs the necessary scaffolding. The tool
could output the "main" function. This is what Ruby on Rails does.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list