Top Down Approach in Software Engineering

Top Down Approach

  • A top down approach is also known as step-wise design approach.
  • A top down approach simply refers to the “decomposition” means breaking down a component into sub-components/sub-parts.
  • In the top down approach, testing takes place from top to the bottom which follows the control flow  pr architectural structure of the software system.
  • Top down approach is a integration testing where top-level modules tested first and then lower-level modules are tested in a step by step manner until all the modules are not tested.
  • In this approach, only the top most module is tested separately after that all the lower level modules are combined one by one and tested to ensure that the system is working as expected. This process is repeated until all the modules are combined and tested. 
  • If module at the top is module A and the sub-modules are A1 and A2. So the module A is tested and then sub-modules A1 and A2 are combined one by one then tested So to test the topmost module A, we develop stubs.
  • Stubs are the dummy piece of the code which is used for testing the modules which are not exist for integration. Stubs accepts the requests from the top-level module and return the response which is compared to the expected behavior.
Top Down Approach

Stubs : 

Stubs are also known as ‘called programs’. They are used in software testing which are used to test the basic functionality/working of the modules. Stubs act as a temporary replacement for a module. It also stimulate the behavior of the lower-level modules that are not combined to test the upper-lever modules. Stubs are developed by the software testers team.

There are basically four types of stubs which is given below :-

  1. Displays the trace message.
  2. Values of parameter is displayed.
  3. Returns the values that are used by the modules.
  4. Returns the values selected by the parameters that were used by modules being tested.

Advantages of Top-down Approach :

  • Fault Localization is easier.
  • It is possible to obtain an early prototype.
  • In the top-down approach, critical modules are evaluated on priority and major design flaws could be detect and fixed first . 
  • Top down approach requires few or no drivers.
  • It is more stable and accurate at the aggregate level.
  • The stubs can be written in lesser time compared to drivers.
  • The tested product is very consistent, as the integration testing is basically performed in an environment that is almost similar to that of reality.
  • Representation of the test cases are simple once the I/O functions are added.

Disadvantages of Top-down Approach :

  • This approach requires many stubs.
  • The lower-level modules of the software are tested inadequately.
  • It is difficult to test the upper-level modules.
  • This technique takes cost to create/develop the stubs.
  • The basic working/functionality of the software system is evaluated at the end of the cycle.