Page 232 - DCAP305_PRINCIPLES_OF_SOFTWARE_ENGINEERING
P. 232

Principles of Software Engineering



                   Notes         test is written first so that a well-defined set of criteria is formed that can be used to tell when
                                 just enough code to implement the behaviour has been written. One of the benefits of writing
                                 the test first is that it actually helps better define the behaviour of the system and answer some
                                 design questions. (TDD process is shown in figure: 11.5)

                                              Figure 11.5: Development flow: (a) Traditional Test Last and
                                                     (b) Test-driven Development/test-first Flow















                                 11.2.2 Benefits of Test Driven Development

                                 Test Driven Development contributes to software development practice from many aspects such
                                 as requirements definition, writing clean and well designed code, and change and configuration
                                 management. The promises of TDD can be summarized as follows;
                                 Simple, Incremental Development: TDD takes a straightforward, incremental approach to the
                                 development of software. One of the main benefits to this approach is having a operational
                                 software system almost immediately. The first iteration of this software system is very simple and
                                 does not have much functionality, but the functionality will get improved as the development
                                 continues. This is a less risky approach than trying to build the entire system all at once, hopeful
                                 it will work when all the pieces are put together.
                                 Simpler Development Process: Developers who use TDD are more focused. The only thing that
                                 a TDD developer has to worry about is getting the next test to pass. The goal is focusing the
                                 attention on a small piece of the software, getting it to work, and moving on rather than trying
                                 to create the software by doing a lot of up-front design. Thousands of decisions have to be made
                                 to create a piece of software. To make all those decisions correctly before starting writing the
                                 code is a complex challenge to undergo many times. It is much easier to make those decisions
                                 as developing the code.
                                 Constant Regression Testing:  The  domino  effect  is  well  known  in  software  development.
                                 Sometimes a simple change to one module may have unforeseen consequences throughout the
                                 rest of the project. This is why regression taxing is important. Regression testing is like self-
                                 defense against bugs. It is usually done only when a new release is sent to quality assurance
                                 (QA). By then it is sometimes hard to trace which code change introduced a particular bug and
                                 makes it harder to fix. TDD runs the full set of unit tests every time a change is made to the
                                 code, in effect running a full regression test every time a minor change is made. This means
                                 any change to the code that has an undesired side effect will be detected almost immediately
                                 and be corrected, which should prevent any regression surprises when the software is handed
                                 over to QA.

                                 Improved Communication: Communicating the ideas needed to explain how a piece of software
                                 should work is not always easy with words or pictures. Words are often imprecise when it
                                 comes to explaining the complexities of the function of a software component. The unit tests
                                 can serve as a common language that can be used to communicate the exact behaviour of a
                                 software component without ambiguities.


        226                               LOVELY PROFESSIONAL UNIVERSITY
   227   228   229   230   231   232   233   234   235   236   237