advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Domain-specific Modeling: Making Code Generation Complete

Domain-specific modeling is most successful when the models let you generate complete working code, without the need for post-generation code modifications or additions. The examples and guidelines in this article show you how. 


advertisement
evelopers usually agree that it does not make sense to write all code character-by-character. After coding some features, they usually start to find similarities in the code, patterns that seem to be repeatable. Because nobody wants to write routine code, the idea of code automation—generating the repeatable portions automatically—arises both naturally and repeatedly. The obvious benefits of generators, such as productivity, quality, complexity hiding, and having more time to solve real domain problems, further boost the desire to seek automation.


Varied opinions exist concerning what kinds of code one can generate, and with what level of quality. For example, automation to produce static declarative definitions from common designs such as interfaces or database schemas has been a reality for ages, so multiple off-the-shelf generators are available. However, the situation is different when it comes to generating behavioral, functional code. I would like to emphasize that by generation I mean automatically producing code that is complete from the modelers' perspective. This means that the code is complete, executable and of production quality from the modeler's perspective; in other words, after generation, the code needs no manual rewriting or additions. Although it is possible to edit the generated code, you should avoid doing so. Editing generated code is (or should be) analogous to manually editing machine code after C compilation—typically unnecessary. I'm a strong believer that you should treat generated code simply as an intermediate by-product. That has been the recipe of success for compilers, and code generators can achieve the same objective.

It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement