Debian Codegraph @

DEVELOP

raw
1 DEVELOPMENT NOTES
2 -----------------
3
4 This file contains random development notes. You should have read or at least
5 skimmed it when you intend to customize, port, extend or translate this
6 Application.
7
8 NB: This document is now out of date, but it is a starting point and should be updated soon.
9
10
11 CONTENTS
12 --------
13
14 - ALWAYS RTFM
15 - ADDING FUNCTIONALITY
16 - WHY I DID IT THIS WAY
17 - HOW IT WORKS (probably the interesting bit)
18 - HOW TO ADD A HANDLER (even more interesting)
19 - BENCHMARKS
20 - BUGS
21
22
23 ALWAYS RTFM BEFORE YOU DO ANYTHING.
24 -----------------------------------
25
26 The POD is there for all perl modules - use it. If its not in the POD or if the POD is unclear, email me - I plan to set up a mailing
27 list soon.
28
29 ADDING FUNCTIONALITY
30 --------------------
31
32 Did I say RTFM, well again, read the documentation before you do anything.
33
34 Functionality should be added through extending the current model and/or adding abstraction, maintaining or increasing the
35 componentisation. I have spent a long time ironing out the hacks and bugs and won't put any back in in a hurry.
36
37 If you wish to add functionality then email me a patch, the source and an explaination, if you wish to request a feature also email
38 me. I can be reached at [email protected]
39
40
41 WHY I DID IT THIS WAY
42 ---------------------
43
44 I did it this way as a cruel joke on other programmers. No not really, even if it does seem that way.
45
46 I started doing this project as an afternoons hack but I got interested in it, and I wanted to make it more elegant, in the end it
47 became a full on project and I had to rewrite from scratch using OO, modules and plenty of abstraction. There is still a long way to
48 go in this regard to make it totally componentised so that it can be integrated into a perl script and handle different types of
49 input and output.
50
51
52 HOW IT WORKS
53 ------------
54
55 - The autodia.pl script gets a list of files to analyse from the user, uses File::Find or globbing to generate a list based on the
56 langauge.
57
58 - The autodial.pl script creates an empty Diagram object (using Diagram.pm)
59
60 - The autodia.pl script loads the appropriate handler and passes it the filehandle of each file ( or in the case of DBI a DSN )
61
62 - The handler parses each file in the list and creates a new Class object for each class or in perl package/script, or in c
63 program/library. (using Autodia::Diagram::Class), this Class is added to the Autodia::Diagram object which holds all the objects and
64 provides methods for accessing them.
65
66 - As the file is parsed the handler populates the Class object from any functions/methods, attributes, and relationships it finds.
67 These are added to the Class and in the case of superclasses and packages the Diagram object. (using Autodia::Diagram::Superclass,
68 Autodia::Diagram::Component, etc)
69
70 - After the files have been parsed redundancies are removed and the positions for each diagram entity (ie class, relationship,
71 superclass) are calculated using a simple tree layout algorithm or passed through an external program such as dot or vcg dependant on
72 command line options.
73
74 - If using an external program or using a custom output function (in Autodia::Diagram where this is done) the objects are called to
75 build a set of nodes for passing to an external application or transposing into some text to be output
76
77 - If using a template the template is created and passed the Diagram object, the output file and the template file.
78
79 - If using a template the template then makes calls to the Diagram Object it was passed, which provide lists of diagram entities
80 which it uses to populate the template.
81
82
83 HOW TO ADD A HANDLER
84 --------------------
85
86 To add a handler to AutoDia
87
88 - open Autodia.pm and add the language name and handler name into the %handlers hash in the getHandlers function.
89
90 - add patterns and regex's for finding appropriate files if not already present in the getPattern function.
91
92 - examples and documentation in Autodia.pm, also check Autodia/Diagram.pm which is the core of the Application.
93
94 - create a class that inherits from Autodia::Handler or Autodia::Handler::Perl. You will need to have a method called _parse that is
95 passed the filehandle and does all the diagram and class population. you can add any subroutines you need to make _parse work.
96
97 - the Handler superclass does most of the work along with the diagram classes. see the Autodia::Handler::Perl parser for example code
98 as it is heavily commented and clearly laid out (well as much as possible)
99
100 BENCHMARKS
101 ---------
102
103 Some quick and dirty tests to give you an idea of how long stuff could
104 take.
105
106 Autodia pre 0.05 contains about 2000 lines of code in 7 files.
107 Autodia 0.05 and higher contains about 2500 to 3000 lines in 11 files.
108 Autodia 1.7 (pre-release) contains a total of 5520 lines in 18 files excluding makefiles, etc
109
110 version 1.0: (intel Celeron Mendocino 466mhz running linux 2.4.6)
111 10 loops of autodial.pl took 9 wallclock secs ( 8.87 usr + 0.02 sys =
112 8.89 CPU) @ 1.12/s (n=10)
113
114 On a K2 450, running Linux 2.2.12. AutoDial analysed itself 10 times,
115
116 version 0.09:
117 10 loops of autodial.pl took 10 wallclock secs ( 9.20 usr + 0.24 sys =
118 9.44 CPU)
119
120 version 0.08:
121 10 loops of autodial.pl took 10 wallclock secs ( 9.00 usr + 0.21 sys =
122 9.21 CPU)
123
124 version 0.06:
125 10 loops of autodial.pl took 10 wallclock secs ( 9.32 usr + 0.23 sys =
126 9.55 CPU)
127
128 version 0.05:
129 10 loops of autodial.pl took 11 wallclock secs ( 9.68 usr + 0.27 sys =
130 9.95 CPU)
131
132 version 0.04:
133 10 loops of autodial.pl took 9 wallclock secs ( 8.36 usr + 0.08 sys =
134 8.44 CPU)
135
136 version 0.02:
137 10 loops of autodial.pl took 8 wallclock secs ( 7.09 usr + 0.13 sys =
138 7.22 CPU)
139
140 version 0.01:
141 10 loops of autodial.pl took 6 wallclock secs ( 5.94 usr + 0.09 sys =
142 6.03 CPU )
143
144 ######################################################################
145
146 Please submit bug reports, code, examples, test code, etc to [email protected] , see
147 http://www.aarontrevena.co.uk/opensource/autodia/ for details and news.