Tips for Agile Development with Unit Testing approach.

14 / Jul / 2010 by Salil 1 comments

This is more towards the best practices and my experiences for developing an application at a faster rate.

In my current project, we are using many different APIs (for external services). And usually it takes time to explore, implement and then stabilize the application. Also, it’s not over once you stabilize your APIs based code. Because there are possibilities to have unexpected results such as server side errors, broken request, broken response, etc. Also you never know when Service provider makes some changes and your code breaks.

Well, here are some tips which really helped me to achieve faster implementation and more stable application (esp. when working with third party APIs).

TRY TO MAKE YOUR CODE UNIT TESTABLE as much as possible.

1. Create Service layer for API based implementation. Keep this service layer independent from other application. So that you should run it without any other dependency.

2. Try to make small chunks of code (in form of methods) with least dependency on external things.
Avoid Domain/Database/Environment specific code. In other words, don’t put any kind of framework specific dependency. In some cases you can’t avoid. But try to avoid as much as possible. Because it could lead to integration testing and which again takes more time. Unit test is the fastest way to check your code stability.

3. In case you have some dependencies (and that can not be avoided) – Try to mock it up. In many cases it’s possible. If you are using Grails/Groovy kind of framework/language – you have an edge to take an advantage of meta-programming.

4. There is no specific way to do this. But it comes with practice. You can follow above tips to implement your Service Layer Code. And then create unit tests – invoke your API based service methods. And run it. Wow.. that’s it.

Advantages:
If there’s any kind of changes (from service provider), that can break your application’s functionality, test driven development will work as a “Life Saver”. It can tell you where’s the problem and why it happened. And you can make appropriate changes to stabilize it again.

Same thing implements when you develop a new feature. Unit Test Case helps you see the results in few seconds. Instead of waiting for 10-15 minutes (until application starts).

Isn’t it cool?

I really appreciate this approach. Hope others will also use it.

Thanks
Salil Kalia

FOUND THIS USEFUL? SHARE IT

comments (1 “Tips for Agile Development with Unit Testing approach.”)

  1. Tushar

    Hi, thank you for this post I agree with you that If there’s any kind of changes (from the service provider), that can break your application’s functionality, test driven development will work as a “Life Saver” . very useful information

    Reply

Leave a Reply to Tushar Cancel reply

Your email address will not be published. Required fields are marked *