Introducing Parsware Code Generator

Parsware Code Generator

Introduction

When I started programming in my first commercial project back in early 2000, I noticed development is not always an algorithm intensive job that you are going to enjoy every minute of it.

Back then we were working on a project for an insurance company and development environment was Oracle Developer 2000 and database management system we used was Oracle 8i. Awesome days, and I was really enjoying the job. But you know what? it quickly got boring because there were lots of repetitive jobs that I did not love, mostly copy and pasting similar codes. Maybe you still do it somehow, but I needed a better way. So I was thinking about a quicker, more systematic way to produce code. Then was the time I came up with the idea of a code generator. Of course it took  lots of years to evolve. Check out the amazing history of Parsware Code Generator. The idea is to model the application and its layers in a data model and then feed these models to template engine and template engine generates code based on templates provided for it.

Code Generator Flow
Code Generator Flow

We keep design model of applications in a hierarchy. This hierarchy models layers of application, entities, tables, user interface views, actions and controls and their respective relations. We feed this hierarchy to template engine which uses templates to create final code files for different parts  and layers of application.

Hierarchy of code generator model
Hierarchy of code generator model

History

First version was a simple Visual Studio add on that simply did the copy/paste job. I think it was working in Visual Studio 2002. Back then it was looking amazing, you could even see code replacements in Visual Studio.

Second version was a win form application named ‘Parisa’ which was developed by C# and was generating a win form and web form 3 layer applications with UI (user interface) BLL (Business Logic Layer) and DAL (Data Access Layer) layers. In those days it was awesome but not enough. Having a dynamic model always been a problem, in fact for any type of application, you need a way to create a model dynamically and quickly. This was not quite possible until the recent version of code generator.

Three Layer Architecture
Three Layer Architecture
Second version of code generator
Second version of code generator

It also contained a code model to dynamically create new models for new generators.

Second version new project dialog
Second version new project dialog

The next version was a Domain Specific Language (DSL) extension for Visual Studio named ‘Pars’ with static model, because its not simply possible to dynamically create DSL models, if you know a way to dynamically create DSLs let me know because it will let us create dynamic code genrators for visual studio. It was the first wonderful generator I had ever made. It was working inside Visual Studio and generated files was automatically added to solution explorer. Back then generated code was mostly ASP.Net Web Forms and layers assemblies. Still all in Microsoft world.

Pars first DSL extension
Pars first DSL extension

After ‘Pars’ which was working on Visual Studio 2005 and 2008 I had to upgrade. The next version was ‘Pars2’ a Visual Studio extension which was working in Visual Studio 2010. This version payed of and I did big projects in Banking and Industry. Generated code was Asp.Net MVC 3 for user interface and layers assemblies. Beside applications a Report Generator and a Workflow Management System also generated by Pars2.

Pars2 DSL extension
Pars2 DSL extension

In Pars2 I removed swim lines because they was not so much in demand although they where representing layers of application.

Next version was Pars3 which was a WPF user interface for DSL extension in Visual Studio 2012. That ofcouse was not too much improvement as you know working on WPF is much much harder than working on any other technology. Some developers believe in WPF you can always find a way to do what you want to do, but I think leaning curve and remembering the relation of concept is not an easy day to day job. Compare it with web technologies, if you forget any thing from Bootstrap 4 for example you can easily find it on bootstrap web site. Thats why we did not continue that branch. Unfortunately I don’t have any images for Pars3 version.

Next was another 2 or 3 versions of DSL extension and then I came back to Win Form version again but this time it was possible to have a dynamic model structure that let us to create any kind of generator for any kind of application. Even DSL extensions was generated with this new version of code generator. But as you can see all of these generator was bound to Visual Studio and all Microsoft technologies. I love Microsoft but it was time to have multi platform code generator that could be used in MAC computers for iOS app development and Linux computers for multi platform development.

Pars Dynamic code generator extension
Pars Dynamic code generator extension

Here is the last DSL extension generated by dynamic Win Form version of Parsware Code Generator. It got complex and amazing in nature which supported story boards and transitions in web and mobile applications. Templates were in T4 format for most of these generators except the early ones which I was using my own template engine. This version also generated code for wordpress apps and single page applications based on Angular and mobile apps based on ionic framework.

Last DSL extension
Last DSL extension

Multi Platform Version

To support multi platform solution I created the new version of code generator and a template engine based on typescript and a text template generator very similar to T4. With this new version every developer can simply create their own generator models for every specific app that can be modeled. Too much features included in this version that helps a lot.check out the documentation for more information.

Parsware Code Generator
Parsware Code Generator

Conclusion

I am using code generator for years and I can say it gives me power for software development. In fact its changing your method of software development. Its like you having a production line for your software development and giving every developer the power of multiple developers. It keeps the structure of software intact over time and by changing development team. Parsware Code Generator lets you focus on business rules and frees your resources from spending time on time consuming jobs like user interface development. Eventually you get into a point that you have templates for every scenario of the application in your code generator, that’s the time you really feel the power.