On the other hand, you could count selected keywords and functions such asif, then, else, begin, end, and assignment (:=). Your count in this case would benine. Although the choice is arbitrary, you must be explicit and consistent.For my work, I have adopted the following simple guideline:▫ Count logical statements such as, for example, every semicolon and selectedkeywords.▫ Write every countable statement on a separate line.▫ Count all statements except blank and comment lines.▫ Count each language separately.These guidelines produce open and clean-looking code that looks like thepreceding nine-line example. It also simplifies automatic LOC counting. Blanksand comment lines are not counted because the number of logical program statements generally determines the development effort. If, however, you find that thetime required to write comments is significant, then you could decide to count3.3 Establishing a Line-of-Code Counting Standard 41them. The way to decide this would be to measure size with and without counting comment lines to determine which provides a higher correlation with development time.3.4 Size AccountingEven after selecting the size-measurement definition, there are many ways to usethe measures. This is particularly true when you work on a development team thatproduces multiple versions of large legacy products. To track all of the programchanges and additions and to gather the data you need for estimating, you must usea size accounting system.
Although size seems like a simple concept, size measures can be hard to track
if they are not properly defined and used. For example, if you started with a 1,000-
LOC program and added 100 LOC, the result would be 1,100 LOC. If you merely
wrote a new 100-LOC program, however, the result would be a 100-LOC program. Although this result seems obvious and the development effort would probably be roughly comparable, the sizes of the resulting products are vastly different.
Size accounting will help you to understand and properly use size data. The basic
program elements in the size accounting system are as follows:
▫ Base: This is the measure of the initial unmodified base program to which
subsequent enhancements are added. For a new program, the base size would
be zero.
▫ Added: This is the new code that is added to the base. Again, for a new program, the base size would be zero and the added code would be all the code.
▫ Modified: The modified code is that part of the base code that is changed.
▫ Deleted: The deleted code is that part of the base code that is removed and
not used in the next program or program version.
▫ Reused: When an existing program or program routine is copied from
some library or otherwise included in a new program, it is counted as reused
code only if it is unmodified. If it is even slightly modified, the size of this included program is included in the base size and the changes are counted as
modifications.
▫ Added and Modified: For many kinds of software development work, the effort required to write a new LOC is roughly comparable to the effort required
to modify an existing LOC. In these cases, it is convenient to combine the
Added size measures and Modified size measures into an “Added and Modified” size measure. This is the measure generally used in the PSP exercises for
estimating development effort and for measuring and managing quality.
42 Chapter 3 Measuring Software Size
▫ New Reusable: A common development strategy is to build a library of commonly used functions and to reuse them whenever they are subsequently
needed. Because this strategy can save a great deal of effort, the PSP includes
a New Reusable size measure for the newly developed code that is planned
for inclusion in the reuse library. If you rework base code to be reusable, also
mark it with an asterisk.
▫ Total: Total program size measures the entire program, regardless of how its
parts were produced.
The reason to track program additions, deletions, and modifications is illustrated in Figure 3.3. Starting with version 0, which has a counted size of 350 LOC,
you add or modify 125 LOC. Thus, you expect to have a finished version 1 of 475
LOC. When you measure version 1, however, its total size is only 450 LOC.
Where did the 25 LOC go?
This can best be explained by using the size accounting format shown in
Table 3.2. Here, starting with a new program base of zero LOC, you develop 350
new LOC, for a total of 350 LOC in version 0. This 350 LOC is the base on which
you develop version 1. In developing version 1, you add 100 LOC and modify 25
LOC of the V1 base. The 125 LOC is thus made up of 100 LOC new and 25 LOC
modified. Notice, however, that the 100 LOC are shown only in the Added column
on the left of Table 3.2, but the 25 LOC are shown in both the Added and Subtracted
columns. The reason is that a modified LOC must be counted as a one-line addition
and a one-line deletion. This is because that line is already counted in the base. If
you don’t subtract the 25, you will double-count it. Version 1 (or version 2 base)
now is shown to contain 450 LOC, just as the counter indicated.
đang được dịch, vui lòng đợi..
