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