Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

84 lines
3.8KB

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