Unit 4
Unit 4
CODING PHASE
Coding Techniques
• It includes –
1) Single Entry, Single Exit constructs,
2) Data Encapsulation,
3) GOTO statements,
4) Recursion
Single Entry, Single Exit constructs
• All the statements in these types of constructs
can only be represented in three basic forms –
a) Sequencing, b) Selection, c) Iteration.
• This construct permits nesting of constructs within one
another in any desired fashion. Each ‘Sn’ statement
might be an assignment statement, a procedure call, a
conditional statement or a looping statement. The most
important aspect of this type of construct is the
linearity of control flow.
• These constructs sometimes show a disadvantage of
inefficient memory space utilization and more
execution time, due to the use of auxiliary variables,
repeated segments of code and excessive subprogram
calls.
Data Encapsulation :-
Ex.
if(condition)
if(condition)
if(condition)
{
statements;
}
else
{
statements;
}………
4) Don’t nest too deep :- Nesting of looping and
conditional statements should be avoided and
if at all necessary the depth of nesting should
not be more than 3 or 4 levels
5) Avoid sub optimization: - Sub optimization is the process
where time is invested on improving and refining that part
of code which is a very small part of entire system. Sub
optimization should be avoided because of the following
reasons :-
– Firstly, it’s usually not possible to determine that which part of
the code will occupy the majority of the execution time until
various execution characteristics of the complete program if fully
studied.
N = n1 * log2 n1 + n2 * log2 n2
Program Effort
E=V/L
Where
N1 – Total number of operators in a program.
N2 – Total number of operands used in the program.
n1 – Number of unique operators in the program.
n2 – Number of unique operands.
Verification and Validation