Code Generators or T4 Templates, are they really evil?

前端 未结 15 1430
[愿得一人]
[愿得一人] 2021-01-31 12:19

I have heard people state that Code Generators and T4 templates should not be used. The logic behind that is that if you are generating code with a generator then there is a bet

15条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 13:05

    Why does being able to copy/paste really, really fast, make it any more acceptable?

    That's the only justification for code generation that I can see.

    Even if the generator provides all the flexibility you need, you still have to learn how to use that flexibility - which is yet another layer of learning and testing required.

    And even if it runs in zero time, it still bloats the code.

    I rolled my own data access class. It knows everything about connections, transactions, stored procedure parms, etc, etc, and I only had to write all the ADO.NET stuff once.

    It's now been so long since I had to write (or even look at) anything with a connection object in it, that I'd be hard pressed to remember the syntax offhand.

提交回复
热议问题