Question

I need to speed up my coding, too much work, so I need be able to generate code. Any tools, any ideas?

Was it helpful?

Solution

Delphi includes Live Templates, a completely scriptable and configurable system for generating code constructs of any size or complexity.

Live Templates are, in my view, one of the more under-appreciated features in Delphi.

Find out how to use them at: http://delphi.wikia.com/wiki/Delphi_Live_Templates

and

http://delphi.wikia.com/wiki/Live_Templates_Technical_Info

Live templates are completely scriptable, meaning you can write Delphi code to do whatever you want with them.

An extendable example can be found here:

http://cc.codegear.com/Item/26420

OTHER TIPS

Not a very good idea IMHO. If you need generator, then probably you have lots of code that looks very similar, so instead of generator, better thing would be to rethink and refactor code you have.

That should result in less code that is easier to maintain and less code in future for similar tasks.

If you are doing database application, then you could use some good visual SQL query builder to help you create queries. That is part that Delphi was not very good (I don't know if it improved in D2007 and D2009)

EDIT - Regarding SQL generation

There's lots of comments about query builder.
Well, I suppose I'm spoiled. As I remember, Delphi before version 6 (or maybe even 5?), had decent visual query builder. I had 0 (zero) bugs in SQL when I selected fields in query designer, opposed to writing SQL by myself.
SQL is just string in Delphi, there is no compiler checking, so this was the best way to ensure that SQL is correctly written.

If you mean something like a modeling tool, you could try out ModelMaker.

Rather than trying to code generate, you should probably just obtain code to do the bulk of what you want to do.

There are hundreds of free products at Sourceforge for Delphi.

And there are hundreds of thousands of code samples at Google Code Search that you can use.

Plus lots thousands of free or purchaseable components at repositories such as Torry's Delphi Pages or Embarcadero's Code Central for Delphi

Using components already made is the fastest way to speed up your coding, and to add capabilities that you would never have been able to.

For me best way is by creating custom components, and then create designer for this component.
I have find that i spent most of the time writing code that read/write values from controls. So i created control that can read, write, validate values, and automatically fill form or stored procedure or directly generate SQL and execute.

Custom designer allows you to setup all properties easy. Now i don't write code for such trivial task i just put control , open designer and set properties and rules that must be satisfied.

ModelMaker Code Explorer speed up my coding in times. It has a nice hotkeys for synchronising implementation and declaration, so if you changed one, you don't have to search for it pair. Also, very nice feature is, method editing dialog. And many more.

Have you tried GExpert? It is a set of tools built to increase the productivity of Delphi and C++Builder programmers by adding several features to the IDE. GExperts is developed as Open Source software.

Other alternative is using project template by saving a framework into the IDE Repository, create your own components and frames.

I wrote a code generator calle CodeTypo. I'm used it in many production environment. You can find it here: http://dade2000.altervista.org/index.php?page=CodeTypo

It's still in beta phase but is usable and reasonably stable.

I'll migrate all content of this old site in the new one (www.danieleteti.it) in english. And I'll add some other info about CodeTypo and code generators.

The thing that sped up my Delphi coding the most was getting CodeRush for Delphi (via a DevExpress VCL subscription for Delphi 5, 6, 7) and setting up a ton of templates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top