-
Notifications
You must be signed in to change notification settings - Fork 0
Generating Overview
SoftFluent CodeModeler is a model driven software factory which based on a producer logic, will generate (or 'produce') platform optimized code.
Starting from a platform independent model which defines the business logic of your application, CodeModeler will build an in-memory meta-model which will be translated into platform dependent code by producers. For instance, the Microsoft SQL Server Producer will produce from the meta-model all corresponding database objects: namespaces will become schemas, entities translated into tables, views into views, methods into stored procedures and so on.
By default, CodeModeler ships with a set of standard producers such as the Microsoft SQL Server Producer, or the Business Object Model Producer allowing you generate the plumbing code (and even more) of many layers of your application.
Nonetheless, we don't intend to replace developers, and we don't think a full enterprise-class application can be entirely generated: there will always be some very specific screen or logic that will require hand-made code. Therefore, the code focuses on recurrent, low value, but necessary needs, freeing developers so they can focus on the real part.
Finally, all generated code is fully extensible and customizable by developers.
Producers englobe a set of concepts which can be global to all of them or local to a specific producer.
Global concepts are concepts that are independent from the targeted platform and shared by all producers. Among those concepts, global ones are for instance the capability to enable or disable each producer, name them, or the fact that all of them have their own namespace.
Another important global concept is that producers, as the name suggests, produce code. Source code are text files, and depending on the producer, the production behavior of those text files can differ from one another. However, this behavior can be configured through the productionFlags attribute of each producer node.
On the contrary, local concepts are concepts that are often specific to a targeted platform, hence specific to a producer. In those cases, the producer will provide extra designed attributes that the developer can use to customize the output for the targeted platform. Those attributes are available in the producer’s category in the Visual Studio’s property grid.
Furthermore, in a project's lifetime, one may not want to generate all the layers all the time. Therefore, CodeModeler offers a simple way to control layers' generation by turning on or off the activation of a producer through their enable attribute which is common to all producers. The sub-section named Controlling Code Production provides information on how to control production aspects.
When using the Visual Studio, the generation process is naturally integrated with Visual Studio's Build command. Behind the scene, this process uses the CodeModeler Meta Compiler, named CodeModeler.Build.exe which is located in the %localappdata%\Microsoft\VisualStudio\16.0_26dd5244\Extensions\SoftFluent S.A.S\SoftFluent CodeModeler\1.3.0.0
directory (adapt 16.0_26dd5244 and 1.3.0.0 to the Visual Studio instance you’re using, and the CodeModeler version, respectively). CodeModeler.Build.exe can be used outside of Visual Studio, if required.
Producers generate platform specific code, mostly source code, text files. Projects can be source controlled and in those cases being able to customize the file generation behavior (e.g. should it overwrite or not) can be handy.
All producers have common configuration attributes that can be changed using Visual Studio property grid. To do so, you must select a producer node (a child of the Producers folder node in the CodeModeler project) and go to the standard Properties window (or press F4):
Here are the possible values for the “Production Flags” attribute:
-
None by default indicates a producer to not overwrite the file if ever something else than the CodeModeler production modified it.
-
Overwrite indicates a producer to overwrite the file even if it was modified.
-
Don’t Unprotect indicates to a producer it should not attempt to remove the ReadOnly attribute on a file, if it is set.
-
Skip to skip this producer from generating anything
-
Remove Diffs removes unnecessary diff information from generated files. Used to avoid merging conflict when generated files are put under source control.
Note: you can also control a producer using the CodeModeler project properties as explained in the Building chapter.
A producer can be configured either clicking on the “Configuration” attribute in the Visual Studio property grid (see image above) or double-clicking on the producer node under the Producers folder node in the project hierarchy. This will open a dialog box like this one (SQL Server producer):
We can configure settings for the producer, and notably the “Target Directory” which can be a physical path and/or a target project in the same Visual Studio solution.
Note: All property grids in a CodeModeler project have multiple tabs, this is also true for producers. Here is an image of the Advanced Properties tab for the SQL Server producer:
To customize a specific producer for a given concept, you can use the Visual Studio property grid “Aspects and Producers Properties” tab as explained in the Property Grid chapter.
Note: For properties specific to a producer to appear, you must add the producer to the project.
Customization can be defined at any concept level: entity, property, method, parameter, etc.
For example, in the case of the SQL Server producer, if you customize it at entity level, it will have an impact on the generated table (here we define a custom table name):
You can customize it at method level (here we add the SQL Server’s NOLOCK table hint):
- Introduction
- Architect Guide
- Concepts
- Using Visual Studio
- Overview
- Creating a CodeModeler Project
- Visual Environment
- Project Hierarchy
- Design Surface
- Customizing Design Surfaces
- Ribbon Bar
- Property Grid
- Member Format Expressions
- Model Grid
- Method Editor
- View Editor
- Instance Editor and Grid
- Resources Editor
- Inferred Model Viewer
- Building
- Project Physical Layout
- Source Control Support
- Generating
- Aspect Oriented Design (AOD)
- Developer Guide
- The Business Object Model (BOM)
- CodeModeler Query Language (CMQL)
- Starting Guide - Tutorial
- Upgrade From CFE