Model Definitions

Have you ever questioned the nature of your reality? Sometimes, I get stuck in the weeds; there are so many trees that I can’t see the forest anymore… Sometimes, talking things through helps clarify things for me.

In my previous reboot post, I said that the first model type I needed to look into was the model used to define other models: the Model Definition model. The path was clear in my head. This is one of the tasks that I have tackled this week. But the more I built, the murkier things became.

I just finished the work this morning and was able to generate code from models derived from my new meta-model. But while I know that this is fantastic progress and I know it will help me, I seem to have lost some of the vision. I’m somewhat underwhelmed and confused about how it will all fit together.

Don’t get me wrong, I am not complaining. This kind of challenge drives me, and I look forward to those challenges.

Background

One of the most significant recurring issues that I have experienced building the Software Factory is: How can I create new model types? In previous versions, this was prohibitively complicated. This is why I only have 2 models and that both of them have significant issues.

While this has gotten better in v3, which allowed me to create the second model, it was still an extensive and painful many months process.

One of my goals for v4 was to develop a way to ‘easily’ create new models. This would allow me to make multiple smaller models that can be assembled as building blocks to create a more advanced modeling system.

Model definitions

The Software Factory used Model Definitions to help map templates and Genset to specific model objects of a particular data type for a long time. But those model definitions were very static.

For example, take a model that contains multiple objects of the type ‘Entity.’ For the Software Factory to execute a specific template for each of those objects, it needs to associate this template with the ‘Entity’ typed object. The mechanism to map the template to this type is the Model Definition.

The Model Definition is a hierarchy of data types with an id. The intent is to map data types with instances of objects at run time. To do this requires:

  • a definition of each type that describes the document model;
  • a set of UI to populate that model;
  • a way to assign type definitions to a template;
  • a way to assign type definitions to Gensets;
  • a class implementation for each type in the document model;
  • a loader to load the json model document into the software factory.

The hard part is that all those things are in different places and need to be mapping and id to the same implementation type; otherwise, things just don’t work.

Meta-model definition?

So the intent was to create a meta-model definition used to develop new model definitions and have all those elements generated to ensure coherence between all elements.

I first updated the existing model definition service to ensure it contained all the elements I needed. Then I generated:

  • the service where this information is stored;
  • the dotnet client to update the Software Factory;
  • the angular client to update the model definition editor.

Then I updated the V3 to V4 migration system to carry over my existing model definitions to the new format. This ensures that I can still generate code from all my old models and solutions.

Then I updated the model definition editor application model. And I generated a large portion of the model definition editor. I integrated all this into the front-end SF Application Angular project; then, I created a model that is a copy of the new meta-model using the model definition editor.

Then I created a new model provider in the software factory to register and load the new meta-model definition format. This is used to load data from the model service and make it available as objects that can be used by the Software Factory to generate code.

Then I created a template project to test code generation. Then I made a new Genset that targets the new meta-model definition model type and executes the test template.

Finally, I created a build to map the model to the solution and executed it to ensure it was generating code as desired.

Too complicated?

Is it too complicated? Maybe? After all, it’s a very complicated problem space: Writing meta-meta-models for meta-models of models.

This one is really stretching my ability to piece together and comprehend complex systems…

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: