7 Things to Look for in a Code Generator | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (179).NET Core  (28).NET MAUI  (215)Angular  (112)ASP.NET  (51)ASP.NET Core  (83)ASP.NET MVC  (90)Azure  (41)Black Friday Deal  (1)Blazor  (229)BoldSign  (15)DocIO  (24)Essential JS 2  (109)Essential Studio  (200)File Formats  (69)Flutter  (133)JavaScript  (226)Microsoft  (120)PDF  (82)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (949)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (45)Webinar  (52)Windows Forms  (61)WinUI  (71)WPF  (163)Xamarin  (160)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (9)Business intelligence  (55)Button  (4)C#  (158)Chart  (141)Chart of the week  (55)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (71)Development  (663)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (14)Excel  (43)Extensions  (23)File Manager  (7)Gantt  (19)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (513)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (4)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (14)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (113)UI  (393)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (620)What's new  (334)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
7 Things to Look for in a Code Generator

7 Things to Look for in a Code Generator

Before jumping into the critical attributes of a code generator for your project, let us start by answering the “why” you would use one.

Benefits and pitfalls of code generation

The key benefits expected by using code generation are the following:

  • Productivity: by writing less code, especially repetitive code, you save time.
  • Maintainability: less manually written code means fewer bugs and less maintenance.
  • Quality: homogenizing the code increases overall quality, especially with a team of developers with different levels of experience.
  • Evolution: abstracting from lower layers can help in the portability dimension toward various platforms or versions in the long run, increasing the evolution capability.

Though there are expected benefits, there are pitfalls in using code generation:

  • Complexity: by adding a level of abstraction, complexity is increased and often much beyond what has been expected at the beginning once you extend the generation perimeter in terms of technology and functionality.
  • Evolution: though this point is mentioned as a benefit, it is also a potential pitfall, as one can also be slowed by using a generator that does not follow innovation at a sufficient pace or does not evolve to support a technology becoming critical for your project.

Those challenges are quite well explained in this valuable article about code generation from Federico Tomasetti. Here is also an introductory article to the principles of code generation.

Writing your own generator?

Though it is very tempting to write your own code generator, as many developers love to solve complex problems and as it is also a way to fully master your architectural choices (see, for example, Kathleen Dollard’s point of view in this article about principles of code generation), it is also a risky decision.

The thing is that complexity is often underestimated by semi-experienced developers, confident enough while gaining some benefits in the early stages of using their own approach, but not anticipating how complexity will scale up in a nonlinear way. You will end up spending your whole time developing the generator instead of your project.

Except if you are part of a large enterprise with hundreds of developers, which makes it relevant to build your own code generator for the team, it is likely a bad idea to try to build one. You can address the legitimate concerns about architecture by choosing the appropriate code generator(s) for your environment and technology stack.

How to choose your code generator by checking 7 critical keys to success

In our view, there are 7 critical keys to being successful in your projects while using a code generator. Make sure you get a good idea of these keys before it’s too late in your project.
7 Things to look for in a code generator

Code reduction

Though it might seem obvious, the code generator should reduce the number of manually written code lines in a completed project. In our experience, this reduction ends up taking care of 90% of the boilerplate code, often counting from 30% to 50% of the total code. Bugs should be reduced proportionately, as there should not be any bugs (at least theoretically) coming from the generator.
Cost comparision: Principle

Some generators also simplify the syntax, making the coding less error-prone. If a generator requires more coding and description than what you would do manually, stop here; code generators should simplify your work, even if it is normal to have a little bit of a learning curve when starting.

Code performance

The code produced by the generator should not impact performance negatively, except marginally. As an example, it may consume a bit more resources, as the generated code is usually a bit more verbose. The code generator should have been designed with execution performance as a focus to be viable over the long term.

Some generators rely on a heavy abstraction model, which is solved at runtime; this does not behave well in production once the application gets larger and with significant production data volumes.

Code quality

The code produced by the generator should be very efficient at execution and it is also better when it is developer-readable—though sometimes not strictly necessary in fully-abstracted areas—but it is not required to be identical to human-written code.

For example, SQL code generators often add ‘WHERE 1=1’ clauses to simplify the generation process.

Still, human-readability can be useful if there is some debugging that requires digging into the generated code for troubleshooting.

The important thing in the end is to homogenize quality at the top level rather than bottom level.

Open to custom code

Whatever the extensiveness of the code generator and its broad spectrum of features, I do not believe in complete generation of the code. And even if such a powerful generator would exist, we would be outside of the developer discussion.

For this reason, it is very important to use a code generator that has the proper hooks and placeholder to integrate manually written code with the generated code. It can be integrated before the generation process, in the middle of the generated code, or through post-processing after generation.

Of course, I exclude from the discussion the one-shot usage of a code generator. I assume that the code generator is properly designed to regenerate the code without interfering with manual code and protected from the risk of manually overriding the generated code without a process that has been designed to allow this.

Development tool integration

One should remember that productivity is a key promise of code generation. Therefore, it is critical that the code generator is properly integrated in the development tool.

A developer who benefits from automated process but loses the productivity of the development tool by losing critical features such as debugging or powerful editing features such as autocompletion, does not save time in the end.

For the same reason, it is important to integrate in continuous build processes that mean seamless integration in the devops processes and tools. One should be able to add a ‘continuous generation’ step in the overall build process.

Generation speed

For the same reason, reasonable generation time is critical. If the speed of the generation process is too slow, not only does the developer lose time, he loses a bit of concentration of focus.

Of course, one should remember that the generation also replaces manual coding and it is acceptable to have some moments where you wait a little bit, especially if you regenerate a significant part of an application, but there is a matter of balance here, to make sure the developer does not spend half of his day looking at the generator processing the code.

Technology evolution support

Last but not least, the technology support of a generator is a key element in your final decision if you have to choose one. Of course, it has to support your current target architecture and technologies, potentially with portability to different platforms or databases.

But it might be a good idea to make sure it will evolve to support further innovation or future platforms by the way it is designed. Keep in mind that a broader generator in terms of features will by nature be a bit slower to adjust to new technologies.

It is also important to check how compatibility will be guaranteed for a sufficient period. One key indicator is the long-term existence of the generator and the current adaptation and compatibility to more recent technologies.


Choosing a code generator is not so easy and it is critical to consider the elements discussed here, knowing there are numerous tools available as one can see on the Wikipedia page. If you evaluate one for your project, keep our 7 recommendations in mind.

At SoftFluent, we have a long history of selling our own code generator, with a recent version now called SoftFluent Code Modeler (full link to documentation directly available on the website). It basically helps you build a powerful portable business layer from a design model.

Syncfusion provides more than 1,500 custom controls to ease the work of developers on various platforms. Please have a look and use them in your application development:


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed