Community Server

The platform that enables you to build rich, interactive communities
Welcome to Community Server Sign in | Join | Help
in Search

agile

Test Driven Development (TDD)

This TDD is the best development process i have been involved to. The "Red, Green and Refactor" is the most esiest way i have ever exprienced when develop a system. Before this, i majorly use Waterfall model which get a bussines requirement from user first. It take a lot of time and will make a uselees of time.

With this "Red, Green and Refactor", i just doin the simplest , less bug and fastest way to develop a system.

First of all, how to make use of this TDD. First, we must know about Unit Test environment. U can get the environment by using NUnit or Unit Test in .Net framework. And when doing a test, think it is for designing... Not for doin a testing only.

There is step2 tahat involve in thid TDD.

1. Fisrt things is, think as consumer when create a test. As example here :

        I have a student and want to register to the system which whe call it StudentRegisSystem.

         example :
         Student student = new Student();
         student.Name = "Student Test";
         student.ID = Guid.NewGuid();

         return student.Save();

2. Compile after writing a code. We will be promt an error. Create a domain class for student, create properties and Save() method just simple as simple as.
Just writing a code which to be need the code can be compile only. After it can be compile, run a test to the UnitTest. Like Example below:

        example:
        public partial class Student
        {
             private string m_name;
             private string m_id;

             public string Name
             {
                   get { return m_name; }
                   set { value = m_name; }
             }

             public string ID
             {
                   get { return m_id; }
                   set { value = m_id; }
             }
           
             public string Save()
             {                 
                throw new Exception("The method or operation is not implemented.");
             }   

        }

3. And Red signal will be display. The red signal will be displayed marking thar there no implementation yet. So rewriting Save() method just to make the test past. Rewrite like below as at Save() method.

            example:
             public string Save()
             {
                return string.Empty;
             }

4. Compile and run Unit Test again. This time Green light appear. Thats meant the unit test have been pass. And the third factor in TDD is Refactor. At this step refactor your code to be easy to maintain and be read by other programmers which maybe make use of you code. Refactor you code and run Unit Test everytime you make a change. This too make sure thats is no bug after refactor.

The benefit of usinf thid development process is, we will start small. Use this princip, "Think Big, Start Small" . Using this TDD, we can detect a bug before we start a real development. and also, we can design our system while testing it. We have save our time and effort by using TDD. It is veryyy use full of me and maybe for you. Try to make use of it.

Adios.



 

Published Wednesday, October 04, 2006 7:39 AM by hakimin

Comments

No Comments
Anonymous comments are disabled

About hakimin

Software Developer
Powered by Community Server, by Telligent Systems