I am Gayan Belpamulle and this is my web log. This blog includes stuff like my personal details, my photos, my dreams and also some of my nutty works... so, i will be posting my day to day catching to this blog.. enjoy!
Current Status
14 December, 2015
24 July, 2015
Test-Driven Development
Test-Driven Development (TDD) has gained popularity among developers as a methodology to improve code quality and design. However, my early experiences with TDD left me feeling overwhelmed and burdened by the tests themselves. Determined to unlock the true potential of TDD, I embarked on a journey to master this development approach. Through numerous struggles and enlightening discoveries, I have gained a deeper understanding of TDD. In this blog post, I will share my insights and the importance of grasping the TDD life-cycle for effective development.
The TDD Life-Cycle:
- Write the test:
- Run the test (test does not pass):
- Write just enough implementation code to make the test pass:
- Run all tests (tests pass):
- Refactor:
- Repeat:
TDD begins with writing a test that reflects the functionality you wish to implement. This test initially fails, as there is no corresponding implementation code.
Running the test at this stage will inevitably result in failure, given that there is no implementation code yet. This step ensures that you have a valid test case that checks the desired functionality.
With the failing test in place, it's time to write the minimum amount of code required to make the test pass. This step encourages you to focus on writing code only for the specific functionality being tested, avoiding unnecessary complexity.
After implementing the code, run all the tests to ensure that the newly added functionality does not break any existing features. This step validates the reliability and stability of your codebase.
With the tests successfully passing, it's time to refactor your code. Refactoring involves optimizing the code for better readability, maintainability, and efficiency without altering its external behavior. The safety net provided by the tests ensures that refactoring does not introduce new bugs.
The TDD process is iterative. Repeat the cycle by writing new tests for additional features or making improvements to the existing ones. This iterative approach ensures continuous enhancement of the codebase and promotes a sustainable development workflow.
Beyond Testing: TDD for Code Quality and Design:
One common misconception about Test-Driven Development is that it solely revolves around testing. In reality, TDD emphasizes development and design practices, which ultimately lead to improved code quality. The resulting unit tests are valuable by-products that provide various benefits, such as early bug detection, documentation, and a safety net during refactoring.
By following TDD principles, developers are encouraged to think critically about their code design before writing the actual implementation. This upfront consideration of the test cases helps to create modular, maintainable, and loosely coupled code. As a result, TDD promotes a strong foundation for software development, which significantly reduces the risk of technical debt.
Conclusion:
Test-Driven Development is a powerful methodology that, when mastered, can significantly enhance code quality and design. By understanding the TDD life-cycle and its focus on development and design, developers can leverage this approach to build robust, maintainable, and high-quality software.
My journey to mastering TDD has been filled with challenges, but the rewards have been substantial. Embracing TDD has not only improved my coding skills but also transformed my perspective on software development. I encourage fellow developers to embark on their TDD journey, to uncover the hidden potential of this remarkable approach and elevate the quality of their code.
Remember, TDD is not just about testing; it's about fostering a culture of excellence in development.
Happy coding!
11 June, 2015
Interviewing Programmers
Hello my dear senior friends in SW engineering , how do you interview new recruits for programming ?Do you start with phone interview and continue on written tests to face-to-face interview? Eventually it will come down to your experience and gut feeling? Most of times we do it in that way. But we have experienced some best practices of picking "better" programmers!
In an environment like work we need more “practical programmers” than just “good coders”. Because most of times our programmers will need to directly work with end user and understand the requirement from business perspective. So we have more responsibility to choose “right” people from interviews.
We take advantage of intern programs, we hunt down the smart CS/IT students and individually ask them to apply for an internship with us, because if you wait around to see who sends you a resume, you're already missing out.
In one incident tried asking applicant to develop a program, I have used a very general requirement, which doesn't need any domain expertise (telco), but require some programming experience. I normally ask to write mathematical method to calculate something, instead of expecting the programmer to do what I think should be done implicitly, what would be a better indicator in my opinion is to see how the s/he tries to ask questions on the scope of the program, purpose, usage and limitations explicitly. Unless the programmer is very familiar with the purpose of the program, he/she should not assume what is not stated, but should try to elicit them. Also I would like to try asking to write a function using basic formations related to String in Java. This is rather simpler one but ask them to write a production like code and then see if it takes care of obvious things like null string, empty string etc.
Some Popular Posts
-
M.D.K Healthcare Center & Hospital(pvt)Ltd is newly formed private Hospital at Horana with High Tech& High Skilled medical facilit...
-
I had this note from long time in my Evernotes, I thought I should have post it here, so someone might find it useful. Why docker? Cont...
-
Javascript: This is a good method taught to me by my friend to disable any character in the keyboard Within Forms in your web page/ web appl...