Instant sharing with the world
About Me
Jots by Salil Kalia

Salil Kalia



Read My Jots
About me
X
Follow
Tags

Tips for Agile Development with Unit Testing approach.

Jul 14, 2010 04:55 PM UTC   submitted by Salil Kalia    Follow Salil Kalia
Comments (0)           

This is more towards, the practices and experience 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 and 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. Example, server side errors, broken request, broken response, etc. You never know about this, if Service provider makes some changes.

Well, there are some tips, those 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 if others also use it.

Thanks
Salil Kalia
Comments (0)
Add your comment: