This section contains 384 words (approx. 2 pages at 300 words per page) |
The term functional decomposition is used to describe the technique for breaking down a task into a number of smaller and simpler sub-tasks. It is a technique that is widely used in computer programming and it confers many advantages on the design and implementation process.
The goal of functional decomposition is to reduce a system step-by-step to a collection of irreducible fundamental functions, starting at the topmost level of functionality. For example, if we have a program that simulates a lawnmower, the main functional description might be "cut the grass." At each level of reduction, abstractions are projected from the level immediately below. The collection of sub-functions that comprises the decomposed main function are called the "functional hierarchy." Using the lawnmower example, the second level of functionality might include the sub-function "propel lawnmower," which itself could include the sub-functions "start engine" and "rotate wheels."
Sometimes a functionally decomposed design is called "black box design" because each function has an interface, in the form of function parameters, that represents its inputs; a return value that represents its outputs; and a behavior that is fully specified for all combinations of inputs. In other words, the function is opaque like a black box: it does not matter how the function does something; what it does is what matters. In this way, functional decomposition makes testing easier because each functional unit or black box can be designed, coded, and tested independently before being combined with its peers into the next level of functionality in the functional hierarchy.
This reduced testing is extremely important in complex systems. As an example, imagine a simple system that takes four inputs, each one of which can be either true or false. Simple math shows that the number of possible input patterns is 24 or 16. But if this function is broken down into two sub-functions each taking two parameters, then each one has a maximum of 22 or 4 patterns of input. Because there are two functions, the total number of test input patterns is 8, half of the original. And as systems get even more complex, the savings can be immense.
Functional decomposition also encourages code-reuse, as small and useful sub-functions tend to get written into function libraries where they can be used again and again by many different programs and programmers.
This section contains 384 words (approx. 2 pages at 300 words per page) |