Are code generators bad?

后端 未结 26 1676
耶瑟儿~
耶瑟儿~ 2021-02-07 07:44

I use MyGeneration along with nHibernate to create the basic POCO objects and XML mapping files. I have heard some people say they think code generators are not a good idea. Wha

26条回答
  •  情深已故
    2021-02-07 08:29

    The biggest problem I've had with code generators is during maintenance. If you modify the generated code and then make a change to your schema or template and try to regenerate you can have problems.

    One problem is if the tool doesn't allow you to protect changes you've made to the modified code then your changes will be overwritten.

    Another problem I've seen, particularly with code generators in RSA for web services, if you change the generated code too much the generator will complain that there is a mismatch and refuse to regenerate the code. This can happen for something as simple as changing the type of a variable. Then you are stuck generating the code to a different project and merging the results back into your original code.

提交回复
热议问题