Re: UML Code Generator for Pascal
- From: Johann Glaser <Johann Glaser gmx at>
- To: discussions about usage and development of dia <dia-list gnome org>
- Subject: Re: UML Code Generator for Pascal
- Date: Sat, 21 Feb 2009 13:54:20 +0100
Hi!
Am Samstag, den 21.02.2009, 11:00 +0100 schrieb Slavko:
it is good idea for me.
have you tested it with Lazarus code?
Yes, I did. I implemented the export code so that I don't have to type
all the classes, fields and methods by hand.
There are a few downsides of using this approach:
- The order of the exported classes and the fields and methods within a
class is random, so you have to sort everything by hand.
- You have to follow some "drawing guidelines" and "naming conventions"
so that the exporter can do its job.
Little documentation attempt:
- Use "UML - Generalization" arrows for class inheritance.
- Use "UML - Realizes" arrows when implementing an interface.
- Inheriting from one class and implementing multiple interfaces is
supported.
- Set a class to be "abstract" to denote it is an interface definition.
- Comments for methods ("Operations") are supported. They are put in
the line before the method declaration with a '///' style comment
(Doxygen-like).
- Method parameter directions are supported (-> 'Var', 'Out').
- Method parameter default values are supported.
- 'Function' and 'Procedure' are automatically recognized by whether a
return type exists or not.
- Inheritance type is supported: set to "abstract" for 'virtual;
abstract;' methods, set to "virtual" for 'virtual;' methods.
- Array fields are automatically recognized. If the name ends with "[]"
an 'Array of' is used. If the name uses a number with "[1234]", an
'Array[0..1233] of' is used. If the name uses a constant with
"[MaxEntries]" an 'Array[0..MaxEntries-1] of' is written.
TODO:
- Automatically use the keyword "override" instead of "virtual" in
descendant classes.
- Support inheriting from classes which are not drawn (e.g. LCL/VCL
classes)
- Print a list of forward declarations of all classes at the beginning
to avoid declaration order problems.
- Print all classes, fields and methods in a "smart" order (e.g. sort
alphabetically, while this is not really smart, at least sorting
everything by hand is easier).
- Automatically define 'Properties'. Unfortunately the UML standard
doesn't support this and so the Dia dialog has no option to specify
this. So a "code" has to be used.
- Write comments for fields.
- Write comments for method parameters (e.g. by using a big doxygen
comment '(** ... *)' before the method)
- Use "Packages" to split the classes in separate 'Unit's.
- Beautify and comment the export code. Using arrays with "magic number
indexes" for certain fields is bad and tedious to work with.
- Support defining global constants.
- Support defining global types (especially for enums, arrays,
records, ...).
- Apply some sanity checks to the UML diagram:
- multiple inheritance is forbidded
- if implementing an interface, all required methods must be
implemented; alternative: just put all methods there, so the UML
drawer doesn't have to write them twice
- visibility for all methods of an interfaces must be "public"
- don't write the visibility specifier 'public' for interfaces
- no "Attributes" for interface definitions, but properties are
allowed
- default values for method parameters must be the last parameters
Bye
Hansi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]