Tuesday, March 24, 2009

Time for BDD (Behavioural Driven Development)

A deep thought over why software project really fails or was built without actual concentration on the business cases will lead to the fact that the actual requirement was not being captured well, no feasibility study of any kind was taken to check the efficacy of the business case. We understand that Business Analyst, Quality Assurance and of course developers need a collaborative efforts to building software. Do we as developer really test first before writing the code. The test first approach makes for understandability of business requirements from coding and it makes us concentrate on what our requirements really are.

How YAGNI (You Aren't Gonna Need It) can help developers

YAGNI can help us to focus on our development needs, it will allow us to focus on the business/technical cases and reduces large complicated code referred to as code bloat. You really aint gonna need that sophisticated features if its just not helping the software requirements at the moment. I know we developers likes to write the best standardize code that meets with the current practices in our industry, that's cool but are we conscious of the time spent on the sophistication, do we put in mind that business requirements comes first before satisfying our hunger for fine grained development practices.

BDD complements TDD
The current methodologies in software houses is the Agile Methodology, whether it is being practiced in a full fledged manner or it is being tailored against your organization requirements, Agile methodologies favors incremental development over classic water fall approach. Agile methodology was referred to as cowboy coding because of its minimal planning approach, but it has proven to be successful in today's deliverable focused environments.

Agile methodologies encourages Test driven Development which in turn allows us as a programmer/developer/architect to focus more on testability of our code. At a point during the writing of large and complex systems, we loose our confidence in our code if we do not have an automated testing framework that gives us the confidence and boost our moral.

That said and done what is BDD?

Have you ever written a complex system with several many business scenarios. The reasons why systems fails is that we do not fully test all different scenarios that the system can find it self. An agile test driven developer should understand that testing scenarios goes beyond your test and mock passed, but its that your code/system meets the full capabilities and conform to clients needs.

It promotes common domain language between what the business analysts, quality assurance and the developers understand. Developers can save the technical detail when interacting with none technical people. This will enable everyone speaking the same language and everyone having common understand of the business case and where we are at.

A simple non BDD interactions

Business Manager : I want the new software to support staff tracking
Systems Analyst : It will results to us obtaining a tracking GPRS systems and API built around it.

Developers : We need to use a wrapper or/and abstraction, that will be make us not tight with third party tools. Yes it seems there is already a bluethoot API in the corner.

Business Manager : The goal of the system is to allow us know the time which the staff logs onto the systems, the idle time of the keyboard, and internet usage.

Systems Analyst : Ok i see, the provide us with your initial thougths and we can write a behavioural code that will clearify your thoughts.

The interaction above is just an example our understandibility is a neccessity in software development. You will not blame us developers for having a higher level mindsets its our job but we need to understand the business case, in other words we have to interrogate our code and simulate the business cases to get the clearer picture.

Note even the business managers do not know what they fully want, but the BDD will document and give a clearer picture of what the system should do.

Hence we need a user story

Recently i migrated a very complex business scenarios from code into WWF (Windows Workflow Foundation) . This would not have been possible if i do not know the user story. Although, i have to admit that i delt with a document which does not clearly structure the requirements in other of user stories or scenarios, all the same i picked up my own pen, and i wrote an interesting user stories from such document. Here is a simple example :

As a user of the online banking system
I want to loging with with my secure credentials
Then check my account details to see my balance record.

With This scenario, => check my account details
Given , the logging page is active and ready to take my details
And, suplying my real encrypted password
And, my real user name
when, i log in my details
Then, i was redirected to a new bank customer account page
And, I checked my account details.

If systems developers can write out a story out of the big and large software requirements documents, then the remaining code will be less painless because you would not be coding and asking about the story because you already know that the story line is happily ever after.

Watch out for when i display my experience with various BDD frameworks like Nbehave, Dan Norths Blog site, at http://dannorth.net/whats-in-a-story.

No comments: