views:

724

answers:

9

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

+10  A: 

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.

zendar
Couldn't agree more. However, the same applies IMHO to the generation of SQL statements. If there's that much repetition in the queries, why not rethink and refactor (for example create stored procedures and views) there too?
mghie
I was thinking about generating basic CRUD statements - it is easier to do it with visual query builder than coding by hand, so that you are sure that all field names are written correctly.
zendar
OK. I guess the systems I had to implement so far were just not big enough then that I was missing a query generator for those statements.
mghie
Not sure why he should use a visual SQL builder. That doesn't mean quick code.
John Nolan
In earlier releases of Delphi, to use type safe objects (the compiler picks up type mismatches) you get repetitive code with just the type names changed (TypeA is a collection of TypeB, TypeX of TypeY), a problem that was adressed in part by generics. Otherwise Live Templates are the answer.
Chris Latta
+4  A: 

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

utku_karatas
+2  A: 

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.

lkessler
A: 

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.

moobaa
+12  A: 

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

Nick Hodges
+1  A: 

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.

Edin
can you give me a code sample of that?
Jlouro
Sure , but my implementation only works with firebird database, i ll post somewhere, i need few days.
Edin
+1  A: 

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.

+1  A: 

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.

WishKnew
+1  A: 

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.

Daniele Teti