11,000 Lines of Code in 41 Seconds
I'm continuing my work on code automation for my application, AIDBDeveloper. This time, I've set my sights quite a bit higher: generating all the classes needed to implement the editor for this very blog as a class library integrated into the platform.
In my previous article, I took a fairly simple first step: automating resource localisation for a control or form. It involved little more than modifying a few XML resource files and a couple of classes to declare their names.
In this new article, I'll demonstrate a combination of automation techniques. On the one hand, the familiar VSIX project template for creating a Visual Studio project with a custom configuration. On the other, starting from the tables in this blog's configuration database, I'll generate 29 classes (one for each table), a repository class, a common base class for all the tables, an interface for the table objects, and another for the repository.
Two additional interfaces will integrate the repository into the solution: one implemented by the provider component and the other by client components.
I'll also need to modify the standard class I use to integrate these class libraries into the solution, exporting objects that must be available on demand, without requiring their types to be known in advance.
And, of course, I'll need to add localised text resources for all of this, just as I did in the previous article.
So, what will artificial intelligence be doing this time? Essentially the same thing as before: generating the text resources. English and Spanish texts for the categories, names and descriptions used when editing objects in the user interface.
These texts will be stored in a JSON file within the project, so even if I run the process a hundred times, I'll only need AI for the first run.
But there's more. I've standardised how objects are updated in all my database repositories. I always use stored procedures, leaving the SQL complexities to the database. This way, even when several operations are required, they can all be performed in a single call.
That means I'll also need to generate 29 stored procedures, using MySQL in this case, to update each of the tables.
Incidentally, generating all of this takes just 41 seconds when AI is involved. Without it, the process takes less than a second, so making corrections and modifications is a breeze once the JSON file containing the resources is available.
I'll also demonstrate another kind of automation. After all, automation isn't just about writing code. In my .NET applications, I make extensive use of attributes to attach metadata to types and guide various operations.
For example, I can define the default configuration of each column in a DataGridView by decorating the corresponding properties with attributes. I can specify which properties represent primary keys, whether those keys are auto-generated, which properties are foreign keys, and what type of join should be used to link to the referenced table.
I won't bore you with endless, tedious explanations of the code, although I'll highlight some of its more interesting details in the accompanying video. I'm hoping to keep improving the way I explain code in my videos, so any comments or suggestions would be very welcome.
So, without further ado, here's the video. Let me know what you think!









