summaryrefslogtreecommitdiff
path: root/fml/doc/en/tutorial/internals/style.sgml
blob: 84e1d2649a57c09bc00de92d1e6a6de72a1c9dc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!--
   $FML: style.sgml,v 1.1 2005/08/03 13:22:06 fukachan Exp $
-->


<chapter id="programingstyle">
	<TITLE>
	Programming Style
	</TITLE>

<para>
This chapter describes a few topics on programming technique.
</para>

<para>
See
<ulink url="http://www.fml.org/software/FNF/">
FNF
</ulink>
on FML.ORG programming style.
</para>


<!-- ==================================================== -->
<sect1 id="variable-naming-convention">
	<title>
	Variable Naming Convension
	</title>

<para>
It is ambiguous where "default" word in the variable name is proper.
The left side of the naming string is expected to show large scale
such as CLASS.
</para>

<para>
Let us consider article related variables.
We expect $article_* variables for them.
</para>

<para>
It seems better to use CLASS_default_XXX syntax not
default_XXX.
</para>


<sect2>
	<title>
	Structure Of Variable Naming
	</title>

<para>
It seems proper to use systematic naming convension.
For it, we define base class or inheritence of naming syntax.
</para>

<para>
Consider class names. For example, "mail" implies messsage/rfc822
format text.  The input into fml system is a mail, outgoing one is a
mail.  The variable are sub class of "mail" object, so the name is
unified as PREFIX_mail_ATTRIBUTE style.
</para>

<para>
<screen>
mail_XXX
mail_default_XXX

use_incoming_mail_XXX
incoming_mail_XXX

use_outgoing_mail_XXX
outgoing_mail_XXX

use_report_mail_XXX
report_mail_XXX
</screen>
</para>

<para>
Other example (header):
<screen>
header_XXX
header_default_XXX

article_header_XXX
use_article_header_XXX

command_mail_header_XXX
use_command_mail_header_XXX
</screen>
</para>

<para>
We can describe 
<link linkend="list.variables.by.class">
structure of class
</link>
as follows:
<screen>
command {
	SOMETHING_command
	admin_command
}
	
directory {
	XXX_directory
}
	
file {
	template_file
}
	
mail {
	incoming_mail
	outgoing_mail
	report_mail
}
	
message {
	reply_message
}
	
article {
	article_digest (not use digest to show digest of article)
	article_spool  (not use spool to show  spool of article)
}
</screen>
</para>

</sect2>


<sect2>
	<title>
	Example: Standard Pattern (e.g. log.cf lock.cf)
	</title>

<screen>
use_VARIABLE		=	yes or no

# append _dir for directory.
VARIABLE_dir		=	STRING

# append _file for file.
VARIABLE_file		=	STRING

VARIABLE_type		=	STRING

VARIABLE_format		=	STRING

VARIABLE_format_type	=	STRING

VARIABLE_limit		=	STRING (NUMBER but STRING)

VARIABLE_upper_limit	=	STRING (NUMBER but STRING)

VARIABLE_lower_limit	=	STRING (NUMBER but STRING)
</screen>

</sect2>

<sect2>
	<title>
	Example 2: (e.g. acl.cf)
	</title>

<screen>
VARIABLE_restrictions	=	reject_ATTRIBUTE1
				check_ATTRIBUTE2
				permit_XXX

ATTRIBUTE1 			=	PATTERN1
					PATTERN2
					...

ATTRIBUTE2			=	var1
					var2

</screen>
</sect2>


<sect2>
	<title>
	Example 3: (program name prefix)
	</title>

<screen>
PROGRAM_VARIABLE_ATTRIBUTE
</screen>
	 </sect2>


</sect1>


<!-- ==================================================== -->
<sect1 id="design.policy">
	<title>
	A Few Topics On Design And Coding Style
	</title>

<warning>
<para>
See also
<ulink url="http://www.fml.org/software/FNF/">FNF</ulink>
on style.
</para>
</warning>


<sect2>
	<title>
	A Few Cautions
	</title>


<para>
Apply quotemeta() for search key.
</para>


<para>
Use access method for object not handle directly within objects.
Example: To access to main.cf object, not use
<screen>
$curproc->{ ... }->{ main_cf }
</screen>
instead use
<screen>
$curproc->main_cf();
</screen>
style.
</para>


<para>
It is better not to use @EXPORT and @EXPORT_OK.
</para>


<para>
How depth of classes is allowed ? 
two such as String::is_japanese_string() ?
At least 3, I think. 
</para>

</sect2>

</sect1>


<!-- ==================================================== -->
<sect1>
	<title>
	Programming Style Original Idea
	</title>

<warning>
<para>
Here is the original idea log.
</para>
</warning>


<para>
<itemizedlist>
	<listitem>
	<para>
	We can use polymorphism in perl.
	Use it and object composition instaed of multiple inheritence.
	</para>

	</listitem>

	<listitem>
	<para>
	Perl 5's OOP is not OOP. Do not depent on it.
	It just provides simple use of variable
	since variable itself knows the home (object / package). 
	</para>


	</listitem>

	<listitem>
	<para>
	Interface for re-use and abstraction should be OOP style.
	</para>


	</listitem>

	<listitem>
	<para>
	We want to use OOP style in using Perl 5 but
	take care for OOP-ism.
	Balance is important.
	</para>


	</listitem>

	<listitem>
	<para>
	not use deep inheritence.
	</para>
	</listitem>

</itemizedlist>
</para>


<para>
	Programs in libexec/ describes the basic flow of processes.
	They may be allowd to be structured not object oriented programming
</para>


<para>
	Polymorphism and re-use is important
	especially in sub-classes.
</para>

</sect1>

</chapter>