{"id":5997,"date":"2017-09-22T12:38:29","date_gmt":"2017-09-22T12:38:29","guid":{"rendered":"https:\/\/modeling-languages.com\/?p=5997"},"modified":"2017-09-22T12:38:29","modified_gmt":"2017-09-22T12:38:29","slug":"g9-modeler-code-generator-tool-review","status":"publish","type":"post","link":"https:\/\/modeling-languages.com\/g9-modeler-code-generator-tool-review\/","title":{"rendered":"Discover the g9 Modeler and code generator \u2013 Tool review"},"content":{"rendered":"

g9<\/a> (formerly known as Genova) by Esito<\/a> is a modeling environment with advanced code-generation capabilities. Given a domain model and a UI model, you are able to generate full Swing<\/a>, React<\/a>, Angular<\/a> applications<\/strong> (among others), including the database, the data access layer and the client side. You can also add a Web Services \/ Rest backend<\/strong> and create your own generators.<\/p>\n

g9 is distributed as an Eclipse plug-in (not a surprise, given the rich modeling ecosystem<\/a> in Eclipse) and comes with a free plan allowing the generation of apps with up to 12 domain classes.<\/p>\n

As most MDD <\/a>tools, g9 is especially suited for data-intensive applications where the user can benefit from the power of model-driven development to automate as much as possible the large volume of repetitive code to manage the domain classes.<\/p>\n

g9 is especially appealing for professional developers that want to increase their productivity and are not allergic to source code<\/strong> (contrary to other tools, targeting more a business user with no programming expertise and that therefore typically prefer a model interpretation<\/a> strategy with automatic cloud deployment and very\u00a0 limited options to refine \/ add additional behavior to the modeled application).<\/p>\n

\"\"<\/p>\n

Let\u2019s take a deeper look at g9, focusing on the aspects I found particularly exciting.<\/p>\n

\u00a0<\/strong>Getting Started with g9<\/strong><\/h2>\n

Given that the g9 website is not the fanciest one I\u2019ve seen ????, the best way to get an idea of what g9 can do for you is to install the tool. As I said before, g9 is free for apps up to 12 classes, which is more than enough to understand how the tool works and get a feeling of the power of the tool.<\/p>\n

Installing the tool follows the standard Eclipse procedure of adding an update site for the tool (full installation instructions<\/a>). Once installed, g9 will show up in your Eclipse environment. If it\u2019s the first time you execute g9 and therefore don\u2019t have a valid license, you can easily request a free one filling the form that will pop-up immediately.<\/p>\n

\"g9

g9 ready to use in your Eclipse environment<\/p><\/div>\n

g9 comes with a set of predefined examples, so my recommendation is to start with those instead of creating a brand new project. Each example comes with the sample model and the corresponding generated code so you can take a look at both.<\/p>\n

Modeling your application\u00a0<\/strong><\/h2>\n

There are two main models in a g9 application: the domain model and the UI models<\/strong> (dialog models in the g9 terminology).<\/p>\n

The domain model is not modeled using g9 itself but automatically imported from a variety of sources like Enterprise Architect<\/a> or Ecore\/Xcore (adding Papyrus<\/a> to the list would be nice as well!). The domain model can include all the typical modeling primitives for static models (classes, associations, attributes, enumerations, generalizations,\u2026). Complex associations (n-ary, association classes,\u2026) must be normalized\/reified before importing the model. To be honest, this is typically the case in most code-generators that try to reduce the complexity of the generators by focusing on the most common modeling constructs (and no, \u201cnormal\u201d people do not often use n-ary associations in their models, I guess I\u2019m one of the exceptions ???? ).<\/p>\n

The UI model is specified using a WYSIWYG approach<\/strong>, where a Palette with all the possible widgets and controls (that change depending on the features offered by the target platform) allows you to quickly drag and drop in the UI canvas. I found it quite convenient and quick to use to get the forms I wanted.<\/p>\n

\"Example

Example of dialog model, tree view and palette in g9<\/p><\/div>\n

One feature that deserves to be highlighted is the possibility to automatically generate some dialog models (CRUD-like ones) from the domain model<\/strong> so that I don\u2019t need to create all of them from scratch. This scaffolding is something that many programming frameworks offer but something that it\u2019s hardly ever seen in modeling tools (even if I don\u2019t believe this to be too complex to implement). \u00a0In g9 this can be done in two ways:<\/span><\/p>\n

    \n
  1. by selecting a set of classes in the domain model and creating an Object Selection from which then create the dialogs.<\/span><\/li>\n
  2. by selecting a set of classes in the domain model and creating a Dialog for each class.<\/span><\/li>\n<\/ol>\n

    An improvement would be to have a rendering of the form closer to the final aspect of that form in the target technology (i.e. an even more real WYSIWYG). This is part of g9\u2019s roadmap at the moment.<\/p>\n

    Beyond these two core models, you can also configure a database model to define how the domain model should be translated into a relational schema (e.g. mapping options for the generalizations) and one or more object selections, which are subsets of the domain model you\u2019re going to use either in a web service implementation or as a data source for a form in the client side.<\/p>\n

    Generating your application<\/h2>\n

    Once the models are ready you can go ahead with the generation of your full application by selecting any of the numerous generators available.<\/p>\n

    \"code

    Partial list of the code generators available in g9<\/p><\/div>\n

    All generators are highly configurable but g9 makes easy also to create your own generator if needed<\/strong>. New generators can be written in Xtend<\/a> or plain Java. Note that, instead of building a complete generator, you can just extend existing ones by<\/p>\n

      \n
    1. creating just custom widgets and controls to complement the palette available in the dialog model.<\/li>\n
    2. Intercept the code generation process by using one of the available hooks that allow you to write your own code for that specific part of the generation.<\/li>\n<\/ol>\n

      This flexibility and extensibility is one of the key points of g9. We all know how important is for a programmer to recognize himself in the code he manipulates; for the adoption of code-generators the generated code must feel like the handwritten one and adapting the generators to the code style of the company is a good step in that direction. Full source code is available for all generators and you might copy and edit it to your needs.<\/p>\n

      Moreover, g9 distinguishes between your manual code and the generated one. This prevents overwriting your own code when regenerating the application. It\u2019s not full round-trip engineering support (your code is a separated extension of the generated one, it does not get propagated back to the model) but it\u2019s powerful enough for most scenarios.<\/p>\n

      I expect Esito to release additional generators in the future. For instance, I\u2019d like to see a more complete support for REST APIs (e.g. by providing an UMLtoOdata generator<\/a>), or GraphQL (e.g. see our UMLtoGraphQL generator<\/a>) which are becoming more and more popular nowadays.<\/p>\n

      g9 as a migration tool<\/h2>\n

      One of the features I like the most is the tool capability to infer the domain model from an existing application. You can either infer it from a database schema or from Java source code.<\/p>\n

      For the former, you just need to indicate the JDBC database connection parameters and the tables you\u2019d like to import.<\/p>\n

      \"Database<\/p>\n

      For the Java source code, you can either derive the model from plain Java code or first annotate it using g9-specific annotations to better control what (and how)\u00a0 to import the code. JPA annotations are also supported so you may just rely on those as well.<\/p>\n

      In both cases, you get a domain model for free<\/strong>. If then, you add it the dialog models you can then regenerate your application using a newer technology (e.g. moving from a plain Java application to a web-based React one), actually completing a migration of your \u201clegacy\u201d tool at a much faster pace than with a traditional migration project.<\/p>\n

      Of course, if the dialog models could also be inferred from the legacy code, that would be awesome but I\u00b4m afraid this is too much to ask (in fact, this is still an open research topic).<\/p>\n

       <\/p>\n

      At a cost of around 500 EUR for a full license, g9 is really <\/em>affordable and for sure one of the most flexible and adaptable code-generator tools I\u2019ve seen and one of the few with such a deep integration in Eclipse. If you are looking for ways to boost your productivity, g9 should definitely be an option to consider. And if you try it (or are already using it) please share your comments below!<\/em><\/p>\n<\/span>","protected":false},"excerpt":{"rendered":"

      g9 is one of the most flexible code-generator tools I\u2019ve seen. It generates both the front-end, the back-end and the database for you. And it’s fully integrated in Eclipse<\/p>\n","protected":false},"author":2,"featured_media":6005,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[24,208],"tags":[593,592,161,255,594],"hashtags":[],"_links":{"self":[{"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/posts\/5997"}],"collection":[{"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/comments?post=5997"}],"version-history":[{"count":0,"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/posts\/5997\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/media\/6005"}],"wp:attachment":[{"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/media?parent=5997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/categories?post=5997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/tags?post=5997"},{"taxonomy":"hashtags","embeddable":true,"href":"https:\/\/modeling-languages.com\/wp-json\/wp\/v2\/hashtags?post=5997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}