[1.3.0] More control of URIs granted
[htmlpurifier.git] / docs / dev-naming.html
blob44200c83bddb18b2aa2eed29ce89899ccdaacc62
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>
11 </head><body>
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>
18 <p>The classes in this library follow a few naming conventions, which may
19 help you find the correct functionality more quickly. Here they are:</p>
21 <dl>
23 <dt>All classes occupy the HTMLPurifier pseudo-namespace.</dt>
24 <dd>This means that all classes are prefixed with HTMLPurifier_. As such, all
25 names under HTMLPurifier_ are reserved. I recommend that you use the name
26 HTMLPurifierX_YourName_ClassName, especially if you want to take advantage
27 of HTMLPurifier_ConfigDef.</dd>
29 <dt>All classes correspond to their path if library/ was in the include path</dt>
30 <dd>HTMLPurifier_AttrDef is located at HTMLPurifier/AttrDef.php; replace
31 underscores with slashes and append .php and you'll have the location of
32 the class.</dd>
34 <dt>Harness and Test are reserved class names for unit tests</dt>
35 <dd>The suffix <code>Test</code> indicates that the class is a subclass of UnitTestCase
36 (of the Simpletest library) and is testable. "Harness" indicates a subclass
37 of UnitTestCase that is not meant to be run but to be extended into
38 concrete test cases and contains custom test methods (i.e. assert*())</dd>
40 <dt>Class names do not necessarily represent inheritance hierarchies</dt>
41 <dd>While we try to reflect inheritance in naming to some extent, it is not
42 guaranteed (for instance, none of the classes inherit from HTMLPurifier,
43 the base class). However, all class files have the require_once
44 declarations to whichever classes they are tightly coupled to.</dd>
46 <dt>Strategy has a meaning different from the Gang of Four pattern</dt>
47 <dd>In Design Patterns, the Gang of Four describes a Strategy object as
48 encapsulating an algorithm so that they can be switched at run-time. While
49 our strategies are indeed algorithms, they are not meant to be substituted:
50 all must be present in order for proper functioning.</dd>
52 <dt>Abbreviations are avoided</dt>
53 <dd>We try to avoid abbreviations as much as possible, but in some cases,
54 abbreviated version is more readable than the full version. Here, we
55 list common abbreviations:
56 <ul>
57 <li>Attr(s) to Attribute(s)</li>
58 <li>Def to Definition</li>
59 </ul>
60 </dd>
62 <dt>Ambiguity concerning the definition of Def/Definition</dt>
63 <dd>While a definition normally defines the structure/acceptable values of
64 an entity, most of the definitions in this application also attempt
65 to validate and fix the value. I am unsure of a better name, as
66 "Validator" would exclude fixing the value, "Fixer" doesn't invoke
67 the proper image of "fixing" something, and "ValidatorFixer" is too long!
68 Some other suggestions were "Handler", "Reference", "Check", "Fix",
69 "Repair" and "Heal".</dd>
71 <dt>Transform not Transformer</dt>
72 <dd>Transform is both a noun and a verb, and thus we define a "Transform" as
73 something that "transforms," leaving "Transformer" (which sounds like an
74 electrical device/robot toy).</dd>
76 </dl>
78 <div id="version">$Id$</div>
80 </body></html>