barcodefontsoft.com

Engineering Criteria for Technologies in Software Drawer pdf417 2d barcode in Software Engineering Criteria for Technologies

Engineering Criteria for Technologies use software pdf417 printer toreceive pdf-417 2d barcode for software Viual Cshap Calls C() f(). class C C() new call D() call f() f(). Overrides x Uses f(). Client class D Figure 7.7. ACB1: Example of anomalous construction behavior. constructed, the call made t Software PDF-417 2d barcode o f () in C s constructor actually executes D::f() instead of its own locally speci ed f (). This is illustrated by the partial yo-yo graph in the right half of Figure 7.7.

The result of the behavior shown in Figure 7.7 can be a data ow anomaly if D::f() uses variables de ned in the state space of D. Because of the order of construction, D s state space will not have been constructed.

Whether or not an anomaly exists depends on if default initializations have been speci ed for the variables used by f (). Furthermore, a fault will likely occur if the assumptions or preconditions of D::f() have not been satis ed prior to construction. In an anomalous construction behavior fault, version 2 (ACB2), the constructor of an ancestor class C calls a locally de ned polymorphic method f ().

A data ow anomaly can occur if f () is overridden in a descendant class D and if that overriding method uses state variables inherited from C. The anomaly occurs if the state variables used by D::f() have not been properly constructed by C::f(). This depends on the set of variables used by D::f(), the order in which the variables in the state of C are constructed, and the order in which f () is called by C s constructor.

Note that it is not generally possible for the programmer of class C to know in advance which version of f () will actually execute, or on which state variables the executing version depends. Thus, invoking polymorphic method calls from constructors is unsafe and introduces non-determinism into the construction process. This is true of both ACB2 and ABC1.

In an incomplete (failed) construction fault (IC), the object s initial state is unde ned. In some programming languages, the value of the variables in the state space of a class before construction is unde ned. This is true, for example, in C++ but not in Java.

Constructors establish the initial state conditions and the state invariant for new instances of the class. To do so, the constructor will generally have statements that de ne every state variable. In some circumstances, again depending upon the programming language, default or other explicit initializations may be enough.

In either case, by the time the constructor has nished, the state of the instance should be well de ned. There are two ways for faults to occur. First, the construction process may have assigned an incorrect initial value to a particular state variable.

Second,. Applying Criteria in Practice Table 7.3. IC: Incomplete construction of state variable fd 1 2 3 4 5 6 7 8 9 10 11 12 C lass abstract AbstractFile { FileHandle fd; abstract public open(); public read() {fd.read ( . .

. ); } public write() {fd.write ( .

. . ); } abstract public close(); } 14 15 16 17 18 19 20 21 22 23 24 25 26 Class SocketFile extends AbstractFile { public open() { fd = new Socket ( .

. . ); } public close() { fd.

ush(); fd.close(); }. the initialization of a part Software PDF 417 icular state variable may have been overlooked. In this case, there is a data ow anomaly between the constructor and each of the methods that will rst use the variable after construction (and any other uses until a de nition occurs). An example of incomplete construction is shown by the code fragment in Table 7.

3. Class AbstractFile contains the state variable fd that is not initialized by a constructor. The intent of the designer of AbstractFile is that a descendant class provide the de nition of fd before it is used, which is done by method open() in the descendant class SocketFile.

If any descendant that can be instantiated de nes fd, and no method uses fd before the de nition, there is no problem. However, a fault will occur if either of these conditions is not satis ed. Observe that while the designer s intent is for a descendant to provide the necessary de nition, a data ow anomaly exists within AbstractFile with respect to f d for methods read() and write().

Both of these methods use fd, and if either is called immediately after construction, a fault will occur. Note that this design introduces nondeterminism into AbstractFile since it is not known at design time what type of instance fd will be bound to, or if it will be bound at all. Suppose that the designer of AbstractFile also designed and implemented SocketFile, as also shown in Table 7.

3. By doing so, the designer has ensured that the data ow anomaly that exists in AbstractFile is avoided by the design of SocketFile. However, this still does not eliminate the problem of nondeterminism and the introduction of faults since a new descendant can fail to provide the necessary de nition.

In a state visibility anomaly fault (SVA), the state variables in an ancestor class A are declared private, and a polymorphic method A::m() de nes A::v. Suppose that B is a descendant of A, and C of B, as depicted in Figure 7.8(a).

Further, C provides an overriding de nition of A::m() but B does not. Since A::v has private visibility, it is not possible for C::m() to properly interact with the state of A by directly de ning A::v. Instead, C::m() must call A::m() to modify v.

Now suppose that B also overrides m (Figure 7.8(b)). Then for C::m() to properly de ne A::v, C::m() must call B::m(), which in turn must call A::m().

Thus, C::m() has no direct control over the data ow anomaly! In general, when private state variables are.
Copyright © barcodefontsoft.com . All rights reserved.