overview.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!-- This Source Code Form is subject to the terms of the Mozilla Public
  2. - License, v. 2.0. If a copy of the MPL was not distributed with this
  3. - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  5. <html>
  6. <head>
  7. <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  8. <title>Layout Documentation Overview</title>
  9. </head>
  10. <body>
  11. <h1>Layout Documentation Overview</h1>
  12. <blockquote> Authors: <br>
  13. <ul>
  14. <li>Marc Attinasi (attinasi@netscape.com)</li>
  15. </ul>
  16. History: <br>
  17. <ul>
  18. <li>12/17/2001 - created<br>
  19. </li>
  20. </ul>
  21. </blockquote>
  22. <h2>Background</h2>
  23. The Layout module of Gecko has not been documented very well. This has lead
  24. to some predictable problems: difficult maintenance, hard to get new people
  25. involved in the module, problems assessing the risk of changes, hard to know
  26. where bugs are likely to be in the source. &nbsp;One extreme result of the
  27. lack of comprehensive has been an urge to rewrite some of the more impenetrable
  28. parts of the layout component, the block and Line Layout areas. &nbsp;Rather
  29. than throwing it all away and rewriting it, we have decided to put significant
  30. effort into thoroughly documenting what we already have. this effort will
  31. help us to understand what parts of the system we want to keep as-is, incrementally
  32. revise, or wholesale rewrite. Additionally, we will make the code base more
  33. accessible to new (and not-so-new) engineers.<br>
  34. <br>
  35. <h2>Strategy:</h2>
  36. Documenting all of Block and Line layout is a large task, so it will be
  37. divided up among knowledgeable and interested engineers. Progress will be
  38. tracked in bugzilla <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=115310">
  39. bug 115310</a>
  40. . &nbsp;This document lays out the basic documentation scope and formatting
  41. so that all of the individual contributions can be combined into a relatively
  42. cohesive unit of linked documents. <br>
  43. <br>
  44. <h2>Scope:</h2>
  45. The documentation will generally cover two levels of detail. There is room
  46. for deviation from this as needed, but generally a High Level Design document
  47. and a Detailed Design document will provide the necessary level of detail
  48. for those trying to understand the system as a whole, and those trying to
  49. get into the code.<br>
  50. <br>
  51. <h3>High Level Designs</h3>
  52. High level designs provided an overview of the system being documented.
  53. The general concept of the component is described, and the classes involved
  54. are described briefly (no details of the class implementations). &nbsp;In
  55. some cases the high level design vocabulary consists of other components
  56. and not classes. &nbsp;The important thing is to describe the interactions
  57. between the classes and/or components such that the reader gets an understanding
  58. of which pieces talk to which other pieces, what kinds of data are shared
  59. by various components or classes, how the data is modified and by whom, beginning
  60. states and end states of a process, and external constraints or inputs into
  61. the system begin described. <br>
  62. <br>
  63. A fundamental piece of the high-level design is the<b> data model</b>. This
  64. is generally a graphical representation of the classes or components involved
  65. in the system, showing the relationships between them in terms of has-a,
  66. is-a, uses, owns, etc. the specific representation is not as important as
  67. the content of the representation. For example, using UML or Booch notation
  68. is fine, as is an ad-hoc diagram that shows the same types of information.<br>
  69. <br>
  70. Another important piece of the high-level design is a set of <b>use-cases</b>
  71. that describe specific interaction that result from specific events in
  72. the system. For example, we might want to show specifically what happens
  73. when an attribute is changed on an element via the DOM. Use cases differ
  74. from data models in that they show specific instances of objects or components,
  75. actual data values where interesting or important, and often give a glimpse
  76. into the algorithms employed. All of the components or objects in the use
  77. cases must be documented in the data model.<br>
  78. <b><br>
  79. State Transition Diagrams</b> may be important to some systems, and they
  80. should be documented in the high-level design as well. These should be described
  81. in terms of the abstract states that the system may be in, not in terms of
  82. how the state-machine is actually implemented.<br>
  83. <br>
  84. The high-level documents provide an overview of the components and classes
  85. that make up a system. It can be used as a road map to the related detailed
  86. design documents for the components and classes involved in the system. thus,
  87. the classes, components, and algorithms referenced in the high-level design
  88. document should be linked to the detailed design documents that correspond.
  89. This link generally occurs at the first reference to the class or component,
  90. but it can be provided in other contexts as well, for convenience to the reader.
  91. &nbsp;Missing or invalid links are considered errors in the high-level design.
  92. <br>
  93. &nbsp;&nbsp; <br>
  94. <h3>Detailed Designs</h3>
  95. Detailed design documents provide specific information needed to implement
  96. (or understand the implementation of) the components and classes described
  97. in the high-level design. Users of the classes or components should also be
  98. able to understand from the detailed design just how the classes, components
  99. and API's are to be used. Special performance characteristics of methods or
  100. interactions should be documented where pertinent.<br>
  101. <br>
  102. <h4>Public API</h4>
  103. The public API of the component or class being documented is essential to
  104. the detailed design. Each publicly accessible interface, method and data member
  105. must be documented. Ideally this information is contained in the implementation
  106. files for a class, interface or component. If this is the case, the actual
  107. IDL or class header file can be used as the documentation for the public API.
  108. This should be done as a link or embedded document to avoid the perpetual
  109. need to keep the document up to date with the source file. &nbsp;Specific
  110. items that are important to the description of the publicly available aspects
  111. of the component, class, or interface include:<br>
  112. <ul>
  113. <li>entry-point semantics: what does the method do, or what does the data
  114. member mean? Is the universe of expected clients limited or open (e.g.. who
  115. can call it)?<br>
  116. </li>
  117. <li>preconditions: what are the legal states for the instance to be in
  118. before the entry point is called? what are the legal values for the arguments?
  119. what are the required states for the objects or components used in the entry-point?</li>
  120. <li>postconditions: what is guaranteed when the entry-point is returned
  121. from? what return values are legal? what is the status of the output arguments
  122. for various return states?</li>
  123. <li>special performance characteristics: if there are special concerns
  124. about performance of the method, explain them. for example, is the method
  125. O(n^2)? Is there considerable memory required? Is the method recursive?</li>
  126. </ul>
  127. Beyond the public interfaces, the private and protected methods need to
  128. be documented as well. For protected methods and members, the expectations
  129. of the subclasses must be made clear (e.g.. should the subclass call the
  130. base class method? if so, when?) &nbsp;As with the public methods, the semantics,
  131. preconditions, postconditions, and special performance considerations should
  132. be described. Again, this may be by direct inclusion of the source code files
  133. where appropriate.<br>
  134. <br>
  135. <h4>Algorithms</h4>
  136. There is often a need to document specific algorithms used in methods and
  137. functions. &nbsp;Generally, it is not a good idea to include this sort of
  138. information in the source files, so they must be described fully in the detailed
  139. design document. &nbsp;The extent of this information varies wildly from one
  140. design to another. &nbsp;Be sure to include an Algorithms section to the
  141. document when there are interesting or critical algorithms that the classes
  142. or components employ. &nbsp;Spell out the algorithms in as much detail as
  143. possible using pseudo-code or diagrams. Ideally, it should be possible to
  144. implement the algorithm from the information in the design.<br>
  145. <br>
  146. <br>
  147. Algorithms that involve several different components or object instances
  148. require special attention. These algorithms tend to be more complex and more
  149. difficult to completely specify. &nbsp;Start out by referring to the related
  150. use cases in the high level design, and then drill down into the responsibilities
  151. and requirements of the individual instances involved. &nbsp;Here, diagrams
  152. and pseudo-code are indispensable in communicating how the algorithm is carried
  153. out across the system.<br>
  154. <h4></h4>
  155. <h4> Tech Notes</h4>
  156. The end of the detailed design document should contain a list of links to
  157. Tech Notes. These will vary in depth and scope, but generally they provide
  158. information geared toward helping developers work on the system. &nbsp;Tech
  159. Notes might contain information about &nbsp;how code has been modified, how
  160. a new feature was added, how to debug a certain class of problem, how to
  161. use built-in debugging r logging facilities, or how to maintain or extend
  162. unit tests. &nbsp;The Tech Notes should be stored in a publicly accessible
  163. location, as a comment or attachment in a bugzilla bug, for example. &nbsp;The
  164. text that holds the link should be descriptive of what the Tech Note addresses.<br>
  165. <br>
  166. </body>
  167. </html>