CS504 - Software Engineering I
Course Page
Mcqs
Q & A
Video
Downloads
Short Question & Answers
Q59: What is an Inspection Checklist?
Checklist of common errors in a program should be developed and used to drive the inspection process. These error checklists are programming language dependent such that the inspector has to analyze major constructs of the programming language and develop checklists to verify code that is written using these checklists.
Q60: Give 2 examples of exceptional code paths.
if (e.Title() == “CEO” || e.Salary() > 10000) operator ==() might throw.
cout << e.First() << “ “ << e.Last() << “ is overpaid” << endl;
As per C++ standard, any of the five calls to << operator might throw.
Q61: Give three general rules for avoiding split lines.
For avoiding split lines don’t use these
Break after a comma.
Break after an operator.
Align the new line with the beginning of the expression on the previous line.
Q62: Explain about 3 coverage schemes in white box testing.
Statement Coverage: In this scheme, statements of the code are tested for a successful test that checks all the statements lying on the path of a successful scenario. Branch

Coverage: In this scheme, all the possible branches of decision structures are tested. Therefore, sequences of statements following a decision are tested. Path Coverage: In path coverage, all possible paths of a program from input instruction to the output instruction are tested. An exhaustive list of test cases is generated and tested against the code.
Q63: List five guidelines that can help you in writing portable code.
Stick to the standard: 1. Use ANSI/ISO standard C++ 2. Instead of using vendor specific language extensions, use STL as much as possible.

Program in the mainstream: Although C++ standard does not require function prototypes, one should always write them. double sqrt(); // old style acceptable by ANSI C double sqrt(double); // ANSI – the right approach

Size of data types: Sizes of data types cause major portability issues as they vary from one machine to the other so one should be careful with them. int i, j, k; … j = 20000; k = 30000; i = j + k; // works if int is 4 bytes // what will happen if int is 2 bytes?

Order of Evaluation: As mentioned earlier during the discussion of side effects, order of evaluation varies from one implementation to other. This therefore also causes portability issues. We should therefore follow guidelines mentioned in the side effect discussion.

Arithmetic or Logical Shift: The C/C++ language has not specified whether right shift >> is arithmetic or logical. In the arithmetic shift sign bit is copied while the logical shift fills the vacated bits with 0. This obviously reduces portability. Interestingly, Java has introduced a new operator to handle this issue. >> is used for arithmetic shift and >>> for logical shift.
Q64: Below is the chunk of code : result = squareRoot(argument); assert (abs (result * result – argument) < epsilon); Write the Contract for square root routine keeping in view unit testing.
Pass in a negative argument and ensure that it is rejected  Pass in an argument of zero to ensure that it is accepted (this is a boundary value). Pass in values between zero and the maximum expressible argument and verify that the difference between the square of the result and the original argument is less than some value epsilon.
Q65: Parentheses should always be used as they reduce complexity. Explain it with the help of a single example.
Parentheses should always be used as they reduce complexity and clarify things by specifying grouping. It is especially important to use parentheses when different unrelated operators are used in the same expression as the precedence rules are often assumed by the programmers, resulting in logical errors that are very difficult to spot. As an example consider the following statement: if (x & MASK == BITS) This causes problems because == operator has higher precedence than & operator. Hence, MASK and BITS are first compared for equality and then the result, which is 0 or 1, is added with x. This kind of error will be extremely hard to catch. If, however, parentheses are used, there will be no ambiguity as shown below. if ((x & MASK) == BITS).
Q66: Define Modularity.
Modularity is a tool that can help us in reducing the size of individual functions, making them more readable.
Q67: Differentiate between Architectural Design and System Architecture in one line.
Architecture faces towards strategy, structure and purpose, towards the abstract while Design faces towards implementation and practice, towards the concrete.
Q68: What is meant by Software Debugging?
Debugging techniques are the only mechanism to reach at the code that is malfunctioning.
Q69: Differentiate between Black box testing and white box testing.
In this type of testing, a component or system is treated as a black box and it is tested for the required behavior. This type of testing is not concerned with how the inputs are transformed into outputs. As opposed to black box testing, in structural or white box testing we look inside the system and evaluate what it consists of and how is it implemented.
Q70: Why and how complex expressions should be written in multiple short statements, Explain it with example.
Complex expressions should be broken down into multiple statements. An expression is considered to be complex if it uses many operators in a single statement. As an example consider the following statement: *x += (*xp=(2*k < (n-m) ? c[k+1] : d[k--]));

This statement liberally uses a number of operators and hence is very difficult to follow and understand. If it is broken down into simple set of statements, the logic becomes easier to follow as shown below: if (2*k < n-m) *xp = c[k+1]; else *xp = d[k--]; *x = *x + *xp;
Course Instructor

Dr. Fakhar Lodhi
D.Sc. (CS) George
Washington University, USA
Books

Software Engineering: A Practitioner’s Approach by Roger S. Pressman

The Unified Modeling Language User Guide by Grady Booch