Skip to content

Modeling and Code GenerationΒΆ

Modeling has been a natural part of software development for a long time. But why do we really bother to make a model, instead of just hacking away at the keyboard to create some software? The answer is that by having a model we gain a lot of things that cannot easily be accomplished in any other way.

Here are some of the benefits, when it comes to producing source code:

  • Coding speed
    The amount of time spent on modeling can be gained multiple times by adding automatic code generation that reads the model and creates parts of the source code. A large part of the code will have standard implementation patterns which will be tedious and time consuming to produce manually. Code generation keeps that work to a minimum and lets developers concentrate on the interesting algorithms instead. This means that more development time will be spent on business logic rather than on bulk programming.
  • Code style consistency
    The produced code will automatically have a more homogenous coding style. This is due to the fact that more code is generated directly from the model and will therefore have the same style. Naming of code artifacts will also be more consistent, since the modeling tools can enforce naming conventions and provide good naming suggestions. Consistent coding style makes it easier for other developers to understand what the code does.
  • Code completeness
    A specific problem with software development is to know when a software package is completed and supports all the intended functionality. One way is of course to test everything, but you must have a list of functions that should be there. Naturally, the model supplies with that list. It is far more easy to check that the model is complete then that a bunch if source files are.
  • Code quality
    In a large software system, each component is typically referenced and/or used from many different places. For example, an attribute name is used for database creation, database access statements, data structure definitions, client controls and much more. To ensure that the naming and behavior is consistent throughout the whole code mass, it is easier if we have a single definition that feeds all of these uses. That definition comes from the model.
  • Understandability and documentation
    Instead of having to scan the file system in order to find what you are looking for, the model can be browsed and queried by development tools. These tools can be tailored to support the development process and also to produce adequate documentation, that encompasses not just the developer notes, but also the intent of each component edited by some system analyst of designer. By having documentation in the model itself and not just in the code, documentation text and source code can be edited in parallel. But, modeling is much more than 'just' describing the software components (i.e. implementation models).