4

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

1
  • 1
    Could you please clarify what you need a bit more? I am not sure what, particularly, you mean by 'generate code'. Thanks. Commented Jan 4, 2009 at 17:38

9 Answers 9

17

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

Sign up to request clarification or add additional context in comments.

Comments

11

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.

5 Comments

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?
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.
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.
Not sure why he should use a visual SQL builder. That doesn't mean quick code.
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.
4

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

Comments

2

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.

Comments

1

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.

1 Comment

Sure , but my implementation only works with firebird database, i ll post somewhere, i need few days.
1

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.

Comments

1

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.

Comments

1

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.