Page 380 -
P. 380

Chapter 13   Key points  363


                                       Guideline 8: Name all constants that represent real-world values
                                       All non-trivial programs include a number of constant values that represent the val-
                                       ues of real-world entities. These values are not modified as the program executes.
                                       Sometimes, these are absolute constants and never change (e.g., the speed of light)
                                       but more often they are values that change relatively slowly over time. For example,
                                       a program to calculate personal tax will include constants that are the current tax
                                       rates. These change from year to year and so the program must be updated with the
                                       new constant values.
                                         You should always include a section in your program in which you name all real-
                                       world constant values that are used. When using the constants, you should refer to
                                       them by name rather than by their value. This has two advantages as far as depend-
                                       ability is concerned:


                                       1.  You are less likely to make mistakes and use the wrong value. It is easy to mistype
                                          a number and the system will often be unable to detect a mistake. For example,
                                          say a tax rate is 34%. A simple transposition error might lead to this being
                                          mistyped as 43%. However, if you mistype a name (such as Standard-tax-rate),
                                          this is usually detected by the compiler as an undeclared variable.
                                       2.  When a value changes, you do not have to look through the whole program to
                                          discover where you have used that value. All you need do is to change the value
                                          associated with the constant declaration. The new value is then automatically
                                          included everywhere that it is needed.




                      KEY POINTS



                           Dependability in a program can be achieved by avoiding the introduction of faults, by detecting
                            and removing faults before system deployment, and by including fault-tolerance facilities that
                            allow the system to remain operational after a fault has caused a system failure.

                           The use of redundancy and diversity in hardware, software processes, and software systems is
                            essential to the development of dependable systems.
                           The use of a well-defined, repeatable process is essential if faults in a system are to be
                            minimized. The process should include verification and validation activities at all stages, from
                            requirements definition through to system implementation.
                           Dependable system architectures are system architectures that are designed for fault tolerance.
                            There are a number of architectural styles that support fault tolerance including protection
                            systems, self-monitoring architectures, and N-version programming.
                           Software diversity is difficult to achieve because it is practically impossible to ensure that each
                            version of the software is truly independent.
   375   376   377   378   379   380   381   382   383   384   385