20060802
I call the manually written code handcrafted code because it brings to mind the respect I have for handcrafted items.
Unless there are underlying differences between the three, examples in later sections of this book illustrate only XSLT to keep things focused on the core aspects of code generation beyond how you spit out code.
Each step lays the groundwork for the next step, but it also provides information for refining the previous step.
为下一步奠定基础
The highest payback for code generation is creating middle-tier data containers and data access layers, so a lot of the code in this book focuses on those areas.
最大的回报
I'm so reliant on this technique that even when creating the “Hello World” examples, I first created a target source code file and then copied and pasted it into the template.
信任该技术
As your skills and understanding of code generation increase, you'll contemplate what other sections of your application might be good candidates to move from handcrafted code to autogenerated code.
When the line between the code you should autogenerate and code you should handcraft seems blurry, lean to the conservative side and handcraft more code.
The most important single thing you'll learn from this book may be to become comfortable with design decisions that allow you to combine code generation and class-specific code to provide each class full functionality and personality while retaining your ability to regenerate at will.
Development tends to be a zero-sum game, meaning that extra resources required on one task are taken from another. Too often, resources used by development problems or new features are taken from testing. I hope that as code generation speeds your development, you'll have more time for testing. But I'm not optimistic about it.
Hold generated code to the same high-quality standards you use for the rest of your code, and treat it with the same care—including source control and testing.
These principles are my non-negotiables for code generation:
Although metadata and templates are highly symbiotic, they evolve in response to separate pressures.
高度相互依赖
I want to have my cake and eat it, too!
Code generation is a design-time feature and will have no negative impact on runtime performance.
First, because code-generated parts of your application are repetitively created, if you're in triage mode, you can limit testing to a few examples of each pattern, rather than testing every class. I'm not suggesting this is a good idea, but triage is always a matter of picking the best of bad choices.
两害择其轻
The IndentedTextWriter makes for a few more lines of code but is a less of a pain to keep the code lined up.
导致多几行代码
Don't be concerned if you feel lost or just don't understand the CodeDOM at this point.
别担心
浙公网安备 33010602011771号