The standard application development life-cycle using CodeFluent Entities is as follows:
- Modeling (a.k.a. Design),
- Production (a.k.a. Code Generation),
- Extend or develop if needed,
Those different stages can be repeated as much as needed until your application is complete.
Obviously, only the first three stages (from Modeling to Production) are in fact specific to CodeFluent Entities. On the contrary, the last three ones (from Extend to Run) are in fact standard .NET development stages and CodeFluent Entities doesn't induce anything specific at those stages. In fact, those last three stages are a sub-cycle which can be repeated as much as needed inside the global application development life-cycle. This is so because you don't have to modify the model and generate over again unless you have a structural change such as adding or modifying an entity, a rule, a property, a method, etc.
Dynamic modeling takes place on the inference stage, before any code is generated, which gives you an incredible control over the generated code. Furthermore, the inference stage includes several concepts and is detailed hereafter.
The Inference Stage
A CodeFluent Entities model is a bunch of XML files which are parsed and from them a meta-model will be inferred: XML nodes you defined (e.g. <Product>) will become CodeFluent Entities concepts such as Entities, Enumerations, Producers, etc. which themselves are in fact more global concepts as nodes, and attributes. Therefore, we can say CodeFluent Entities' models are composed of three levels:
- Mx: an infinite set of user-designed concepts (e.g. Customer, Order, Product). defined using a specific XML schema,
- M²: CodeFluent Entities concepts (e.g. project, entity, property, method, rule, procedure, table, constraint),
- M³: a hierarchical Document Object Model (DOM) using mostly Node and Attribute concepts.
|In a nutshell, Mx corresponds to the XML and is parsed, whilst M² and M³ are inferred from Mx.|
Dynamic modeling occurs throughout the inference stage, therefore aspects can work on Mx and other meta-models (M², M³). Furthermore, model inference is divided into ten steps, and aspects can modify the model at any step, influencing next steps. Those ten steps is what we call the inference pipeline.
The Inference Pipeline
When CodeFluent Entities loads a model, it starts building the M³ and M² levels in memory and this is done through several steps, the whole being referred to as the inference pipeline.
The pipeline is composed of the following steps, occurring in the following order:
|Hints||Creation of hints|
|UserTypes||Creation of new user defined types|
|ProjectTypes||Creation of project types (entities, properties, methods, etc.)|
|Tables||Creation of persistence tables|
|Methods||Creation of methods|
|PersistenceViews||Creation of persistence views|
|Procedures||Creation of persistence stored procedures|
|Categories||Creation of display categories|
|UI||Creation of user interface|
|Messages||Creation of messages|
You can plug-in at any of those steps in order to modify the model, and more importantly changes made at a step will be taken into account on the next step. For instance, if you add an entity in the meta-model at the ProjectTypes step, the equivalent tables, methods, views and so on will automatically be inferred from it. Likewise, if we plug-in at the Tables step, we can add a new platform independent table however, a corresponding entity won't be inferred since entities were inferred on the previous step.
In the end, aspects will enrich the model using the CodeFluent Entities R/W API while being loaded into memory.
The CodeFluent Entities API
Using the API (CodeFluent.Model.dll) you can access all levels (Mx, M², M³) of the model:
- Accessing M³ can be done through the library and using XPath expressions on the API (e.g. "/entity[Name='Customer']"),
- Accessing M² can be done through the library (e.g. "if (entity.Name == "Customer")"),
- Accessing Mx can be done through the library or using standard XML APIs (e.g. XmlDocument and standard XPath expressions)
|Note: The CodeFluent Entities API is discussed with more details in the following article: The CodeFluent Entities API.|
Moreover, CodeFluent Entities' schema isn't restrictive. This means that you can add your own XML namespace in your model to add extra attributes, and then access those custom attributes in your aspect.
Points of interest
Key points regarding aspects are that they allow live interaction with the model while CodeFluent Entities is building it in memory. Therefore, this allows you to apply massive changes to a model such as adding properties, methods, rules, and so on to all entities.
Moreover, SoftFluent provides out-of-the box aspects which are shipped along with the product. Importing those aspects in your projects will add functionalities such as data localization or Google-like search to your application.
Finally, you can develop your own aspects so that features such as tracking, Row Level Access Security or multi-tenant support are externalized from your model and can be reused in all your desired projects. Doing this truly industrializes your developments: you invested the time to develop such a feature only once and you can now use it as much as needed wherever you like it.