EvaluationUsing complex conditions

Appropriate use of coding constructs is evaluated to determine the efficiency of software as it relates to use of RAM. Software is measured against the functional requirements to evaluate fitness for purpose.

Part ofComputing ScienceSoftware design and development

Using complex conditions

Using complex conditions can be more efficient than coding multiple single conditions.

In the two examples shown below, the inefficient code makes use of two separate simple conditions and as a result, requires two IF statements.

The efficient version requires only one selection statement. This is because a complex condition is used as part of the IF statement.This achieves the same outcome but places less demand on the processor and available RAM.

InefficientEfficient
IF age ˃= 18 THENIF age ˃= 18 AND age ˂=65 THEN
IF age˂=65 SET ticketCategory TO adult
SET ticketCategory TO adult END IF
END IF
END IF
InefficientIF age ˃= 18 THEN
EfficientIF age ˃= 18 AND age ˂=65 THEN
Inefficient IF age˂=65
Efficient SET ticketCategory TO adult
Inefficient SET ticketCategory TO adult
EfficientEND IF
Inefficient END IF
Efficient
InefficientEND IF
Efficient