1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en"><head>
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"description" content=
"Defines class naming conventions in HTML Purifier." />
7 <link rel=
"stylesheet" type=
"text/css" href=
"./style.css" />
9 <title>Naming Conventions - HTML Purifier
</title>
13 <h1>Naming Conventions
</h1>
15 <div id=
"filing">Filed under Development
</div>
16 <div id=
"index">Return to the
<a href=
"index.html">index
</a>.
</div>
17 <div id=
"home"><a href=
"http://htmlpurifier.org/">HTML Purifier
</a> End-User Documentation
</div>
19 <p>The classes in this library follow a few naming conventions, which may
20 help you find the correct functionality more quickly. Here they are:
</p>
24 <dt>All classes occupy the HTMLPurifier pseudo-namespace.
</dt>
25 <dd>This means that all classes are prefixed with HTMLPurifier_. As such, all
26 names under HTMLPurifier_ are reserved. I recommend that you use the name
27 HTMLPurifierX_YourName_ClassName, especially if you want to take advantage
28 of HTMLPurifier_ConfigDef.
</dd>
30 <dt>All classes correspond to their path if library/ was in the include path
</dt>
31 <dd>HTMLPurifier_AttrDef is located at HTMLPurifier/AttrDef.php; replace
32 underscores with slashes and append .php and you'll have the location of
35 <dt>Harness and Test are reserved class names for unit tests
</dt>
36 <dd>The suffix
<code>Test
</code> indicates that the class is a subclass of UnitTestCase
37 (of the Simpletest library) and is testable.
"Harness" indicates a subclass
38 of UnitTestCase that is not meant to be run but to be extended into
39 concrete test cases and contains custom test methods (i.e. assert*())
</dd>
41 <dt>Class names do not necessarily represent inheritance hierarchies
</dt>
42 <dd>While we try to reflect inheritance in naming to some extent, it is not
43 guaranteed (for instance, none of the classes inherit from HTMLPurifier,
44 the base class). However, all class files have the require_once
45 declarations to whichever classes they are tightly coupled to.
</dd>
47 <dt>Strategy has a meaning different from the Gang of Four pattern
</dt>
48 <dd>In Design Patterns, the Gang of Four describes a Strategy object as
49 encapsulating an algorithm so that they can be switched at run-time. While
50 our strategies are indeed algorithms, they are not meant to be substituted:
51 all must be present in order for proper functioning.
</dd>
53 <dt>Abbreviations are avoided
</dt>
54 <dd>We try to avoid abbreviations as much as possible, but in some cases,
55 abbreviated version is more readable than the full version. Here, we
56 list common abbreviations:
58 <li>Attr to Attributes (note that it is plural, i.e.
<code>$attr = array()
</code>)
</li>
59 <li>Def to Definition
</li>
60 <li><code>$ret
</code> is the value to be returned in a function
</li>
64 <dt>Ambiguity concerning the definition of Def/Definition
</dt>
65 <dd>While a definition normally defines the structure/acceptable values of
66 an entity, most of the definitions in this application also attempt
67 to validate and fix the value. I am unsure of a better name, as
68 "Validator" would exclude fixing the value,
"Fixer" doesn't invoke
69 the proper image of
"fixing" something, and
"ValidatorFixer" is too long!
70 Some other suggestions were
"Handler",
"Reference",
"Check",
"Fix",
71 "Repair" and
"Heal".
</dd>
73 <dt>Transform not Transformer
</dt>
74 <dd>Transform is both a noun and a verb, and thus we define a
"Transform" as
75 something that
"transforms," leaving
"Transformer" (which sounds like an
76 electrical device/robot toy).
</dd>
82 <!-- vim: et sw=4 sts=4