Tuesday, March 6, 2012

Definition of Done - 10 Commandments

At the development team level every team needs to have a definition of DONE which everyone needs to abide by. When someone says a task is "done" before checking in code the following points should be met for it to be really done:

10 Commandments of DONE:

1. Though shalt follow use cases, user stories or other requirement document
2. Though shalt use follow editorial document for any content ( content is the king)
3. Though shalt follow design
4. Though shalt comment your code
5. Though shalt follow naming conventions and coding guidelines
6. Though shalt unit test
7. Though shalt get your code reviewed
8. Though shalt properly test your code’s functionality. Though shalt really not wait for only QA’s to test for you
9. Though shalt consider performance and security while coding
10. Though shalt attach your code to proper work item and add comments while checking in


1. The code is providing functionality as documented in requirement documents like use cases, change requests, user stories etc.
2. If there is any content/text to be displayed it need to be properly added especially if your site is multilingual make sure you add all resource keys.
3. The code is following the approved design for the module/project.
4. The code is properly commented if required. Some methods, classes are self-explanatory. Commenting just for the sake of it is not required.
5. The naming conventions and coding guidelines are followed.
6. A minimum accepted level of unit/integration testing is there.
7. Code is reviewed by another member in your team. This also lets people explore each other's code and can provide support if required (a member leaving the team, absence etc.) It’s also a great learning process.
8. Do at least some basic testing. It is not just QA's job to properly test functionality. Developers should test their code with all possible scenarios etc. before checking in. Also if the code touches or modifies existing functionality a minimum regression testing should be done. This would avoid lot of back and forth between development and QA team and save us lot of time.
9. Performance and security is not something to be pushed at the end and should be considered during development and code review.
10. While checking in attach it to the proper work item and add comments while checking in.

Disable copy paste in an input field

Needed to disable copy, paste in an input field and tried different javascript solutions. It worked on most of the browsers except some versions of IE. After spending sometime with custom java script I gave up and rather tried the following tags in markup which worked in all modern browsers:

<input id="myInput" onCopy="return false" onDrag="return false" onDrop="return false" onPaste="return false" autocomplete=off type="text"/>

More information on these events can be found http://developer.practicalecommerce.com/articles/1906-JavaScript-s-Copy-and-Paste-Events.

Disable div contents with javascript

It is a common requirement to disable ( not hide) div contents on client side depending on certain logic. For example if you have inputs like radio buttons in a div and you want to disable all of them within the given div, you can disable the div to disable selection of any element inside the div.

One way to achieve this via java script is to use the disable attribute.

$('div#myDiv').attr("disabled", 'disabled');

This works in all browsers except firefox. After trying different ways to do it I finally wrote a small script that iterates through your container element (div in this case) and disables them. This works in all browsers.


$(this).attr("disabled", 'disabled');