Do you use code generation tools? [closed]

2020-02-28 04:18发布

Do you use code-generation tools (aside from those used to generate proxies and from designers built-in to visual studio)?

What part(s) of your application do you generate?

Do you typically roll your own generator? If so, what type of generator do you write (asp templates, coddom etc.). If not, what 3rd party tools do you use?

I am currently working on a few different projects wich all use a custom code-generator that handles everything from generating the database structure, business entities, DAL, and BLL. I am curious about other peoples experiences are with these kinds of tools.

18条回答
我只想做你的唯一
2楼-- · 2020-02-28 04:45

Not that we are working in the .net/web domain, but home-made code generations tools from various home-designed languages are a crucial part of our development tool chain. We have two major such tools (with grammars and parsers and formal definitions), and a host of minor one built on macros like m4 and perl. They all generate plain C in the end, which is natively compiled.

Domain-specific languages are one of the key tools for programmer productivity for any large-scale software endeavor in my experience. If you are building things like compilers, simulators, or other very complicated software with many recurring patterns that have no support at all in the basic languages (which typically means portable C and sometimes C++), code generating tools is the way to go. I view domain-specific languages as the next step in generalization: first you break out common computations into functions (or subroutines to be historical), then you break out common functions into templates or generics if such a facility is available, and then you break out even more commonality and repeating code into a full-blown custom language.

It is all about reducing the volume of code you actually write, and removing any form of tedious repetition and non-value-added code from the programming process. As soon as patterns repeat, apply a domain-specific language!

查看更多
狗以群分
3楼-- · 2020-02-28 04:46
  1. We use Code generators for Exceptions
  2. Generating DAO for CRUD operations
  3. use JAXB to genereate code
  4. Use XDoclet to genereate EJB local/home interfaces
  5. Use Velocity templates to generate documentation for business models
  6. Use Apache Axis to generate WSDL stubs
查看更多
够拽才男人
4楼-- · 2020-02-28 04:48

We use LLBLGen to produce our data access layer. You point the generator at the database your using, select which tables you want to use and it churns out the classes needed. It is all very quick and easy.

查看更多
霸刀☆藐视天下
5楼-- · 2020-02-28 04:50

We used to use CodeSmith to generate our NHibernate hbms, our entities, and a few other things. After a while we got sick of this flow so we ditched it.

The T4 generator is free and worth looking into for generation.

We still use the Castle CodeGenerator for MonoRail link generation.

查看更多
叛逆
6楼-- · 2020-02-28 04:54

I wrote a lovely tool in which the experts in the data format I'd written a parser for, could submit their own samples through a web form, look at the output, and tell me whether it was correct.

From that, a jUnit test would be generated. Lovely.

Except that not a single person bothered to use it, and I gathered no test cases whatseover.

查看更多
做个烂人
7楼-- · 2020-02-28 04:54

If interested in LLBLGEN, which is excellent, you might also evaluate subsonic. Maybe even see what Rob Conery has to say about any overlap or interaction between subsonic and t4.

查看更多
登录 后发表回答