Here’s what I mean:
You already pay upfront for fool proof design and detailed requirements. If you leverage more technology to implement your application, rather than spending more on coders, your ROI can go up significantly.
In order for entry-level coders to implement software, they need extra detailed designs. Such designs typically must be detailed enough that a coder can simply repeat patterns and fill in blanks from reasonably structured requirements. Coders make mistakes, and have misunderstandings and other costly failures and take months to complete (if nothing changes in requirements during that time).
But, again… if you have requirements and designs that are already sufficiently structured and detailed… how much more effort is it to get a computer to repeat the patterns and fill in the blanks instead? Leveraging technology through code generation can help a lot.
Code generation becomes a much less expensive option in cases like that because:
- There’s dramatically less human error and misunderstanding.
- Generators can do the work of a team of offshored implementers in moments… and repeat the performance over and over again at the whim of business analysts.
- Quality Assurance gets much easier… it’s just a matter of testing each pattern, rather than each detail. (and while you’re at it, you can generate unit tests as well.)
Code generation is not perfect: it requires very experienced developers to architect and implement an intelligent code generation solution. Naturally, such solutions tend to require experienced people to maintain (because in sufficiently dynamic systems, there will always be implementation pattern changes) There’s also the one-off stuff that just doesn’t make sense to generate… (but that all has to be done anyway.)
Actual savings will vary, (and in some cases may not be realized until a later iteration of the application)but typically depend on how large and well your meta data (data dictionary) is structured, and how well your designs lend themselves to code generation. If you plan for code generation early on, you’ll probably get more out of the experience. Trying to retro-fit generation can definitely be done (been there, done that, too), but it can be painful.
Projects I’ve worked on that used code generation happened to focus generation techniques mostly on database and data access layer components and/or UI. Within those components, we were able to achieve 75-80% generated code in the target assemblies. This meant that from a data dictionary, we were able to generate, for example, all of our database schema and most of our stored procedures, in one case. In that case, for every item in our data dictionary, we estimated that we were generating about 250 lines of compilable, tested code. In our data dictionary of about 170 items, that translated into over 400,000 lines of code.
By contrast, projects where code generation was not used generally took longer to build, especially in cases where the data dictionaries changed during the development process. There’s no solid apples to apples comparison, but consider hand-writing about 300,000 lines of UI code while the requirements are changing. Trying to nail down every detail (and change) by hand was a painstaking process, and the changes forced us to adjust the QA cycle accordingly, as well.
Code generation is not a new concept. There are TONs of tools out there, as demonstrated by this comparison of a number of them on Wikipedia. Interestingly, some of the best tools for code generation can be as simple as XSL transforms (which opens the tool set up even more). Code generation may also already be built into your favorite dev tools. For example, Microsoft’s Visual Studio has had a code generation utility known as T4 built into it for the past few versions, now. That’s just scratching the surface.
So it’s true… Code generation is not for every project, but any project that has a large data dictionary (that might need to be changed mid stream) is an immediate candidate in my mind. It’s especially great for User Interfaces, Database schemas and access layers, and even a lot of transform code, among others.
It’s definitely a thought worth considering.