Introducing Mahana Generator Scaffolding

Over the years (and frameworks) developers have come up with a myriad of tricks and techniques to speed up the process of getting the boilerplate code out of the way so they could focus on writing "the guts". Back when I was working in Codeigniter there were a million "starter kits" you could pull from git, but with no Composer yet there was no easy way to distribute updates and fixes. It also failed for me personally in that, as a developer, I found myself continually growing from project to project and so having to seek out new templates to build from that more closely matched my current ideas.

Laravel 4 came out with a great tool to help this problem with its generators. Now you could speed up the process of creating new classes by working from the commandline; Jeffrey Way's popular Generators package meant you could design a full table migration in much the same way. We could stay in the comfort of our command console and write our application with barely a look at our IDE...and yet.

Something was obviously still missing. Writing a large table from the commandline is not particularly enjoyable, and error prone. The generator stubs weren't configurable, meaning you had to extend the classes and overwrite the methods that read the stub files, and set up your own structure to store custom stubs, if you wanted to do things like extend all your models from a BaseModel and include a custom trait. After a while I found it was quicker to copy/paste an existing model than to `artisan make:model` and then open the file and do all the same editing every time.

This is where I hope Mahana Generator Scaffolding will step in and provide the missing pieces. While thinking over how I'd like to create this library, I came up with the following list of important features:

Classes can be linked individually to different stubs

Class definitions should be written in reusable configuration files

Information in definitions should be more "entity-centric", to be reused in multiple classes where appropriate

In my Perfect World™ I will be able to sit down in a meeting with an open editor and as a part of the note-taking process actually build out the Yaml configuration while interacting with the requesting parties, almost like a live BDD session. A few adjustments back at my desk, run the `generate` command, and my scaffolding is built and waiting for me to add the tests and services needed to run the business logic. Furthermore, for an agency that creates many very similar sites each year, I may already have a module level Yaml file that I can reuse instead of re-writing it all from scratch. This not only speeds up my work but will help to enforce consistencies in naming and style.

I also see another very big benefit from this sort of library in general - the ability to remove uncertainties from the workflow and so allow for better estimates. The more I can remove from the application build and put into a definable, repeatable process, the more I can get acceptance from the client or management side about the parts that are genuinely difficult to estimate because they *are* completely first-time runs. This isn't to say that we want to automate as much as we can for the sake of automation or removing the developer time, but rather that we would prefer to allow the developers to do what only they can do.

So, here is (at the time of writing) my PoC-beta attempt. To make things easier to try out, I have included a genscaffolding.yml file that includes variations on the options available. Tests and proper documentation will, of course, be forthcoming, but at the moment I am trying to avoid over-building until I can have some more interaction with the community about how they envision something like this might be used by their organization.

Mahana Generator Scaffolding

Thoughts & Comments

Thoughts on what direction this might take that would be beneficial to your work style welcome & greatly appreciated!