Hmm, I'm not sure how things work in Zest anymore, but didn't it used to
be so that you could create several Application instances off a single
ApplicationModel?
So you could have several instances of "Module".
These are effectively identical in behaviour and structure, so I guess
they could be thought as "singleton", logically speaking, and thus
caching the instance would make sense.
But wouldn't some things break, if you would get same instance of
Application from calling "NewInstance" (or whatever the method is called
in Zest) of ApplicationModel?
I remember Paul was writing some program, which would instantiate
multiple Applications off a single ApplicationModel.
How things would behave then?
One could argue, that instantiating several Applications off a single
ApplicationModel is 'wrong'.
And for most programs out there, that would be right.
However, I personally did not want to make such restriction to Qi4CS - I
let the user decide what is wrong and right.
If, for some reason, instantiating several *different* Applications off
a single ApplicationModel is something the user wants, then that (s)he
should get.
Also, it feels more 'correct', because of orthogonality, that Assembly
does not know models, but Models know assemblies, and that Models don't
know Instances, but Instances know Models (and transitively Assemblies too).
On 17.12.2015 16:14, Niclas Hedhman wrote:
Right... I kind of agree with you. But end of the day, isn't the Module
effectively a singleton, and like the "Class" will "know" of its only
instantiation... I could also see that it makes sense the other way.
Cheers
Niclas
On Thu, Dec 17, 2015 at 9:32 PM, Stanislav Muhametsin <
[email protected]> wrote:
On 17.12.2015 15:25, Niclas Hedhman wrote:
Sooooo.... I have tried to straighten up the difference between the
"Model"
and the "Instances", especially for the ModuleInstance, which was heavily
overloaded with Model stuff.
The interesting bit about the Modules (and Application and Layer too) is
that there is one model and one instance, so it is possible to go from one
to the other and back. Does that sound right?
Strictly my personal opinion, but no, it doesn't sound right.
IMO instance should know its model, but models should not know instances
that are created off the model.
In Qi4CS I have three layers: assembly, model, instance.
Assemblies are quite close to the ones in Zest - they are the ones that
are manipulated by users of Qi4CS/Zest.
Models are created from assembly - these are immutable, and they
restructure all the type information in assembly into more coherent data
structures.
And, as stated above, instances are created from models.
I've made this layer separation so explicit that even namespaces in Qi4CS
are something like this:
Qi4CS.API.Assembling
Qi4CS.API.Model
Qi4CS.API.Instance
Qi4CS.SPI.Assembling
etc...