Blog

Do not name your method dup (zagorski software tester)

On November 9, 2014, in Syndicated, by Association for Software Testing
0
Credit: Amazon.com

In order to improve my testing skills, I read great book, “Clean Code“, by Robert C. Martin. This book will teach you how to write readable and maintainable code. Either if you do test automation or if you need to read someone else code, this book is for you.

One rule that book teaches you is to name your functions descriptively. They should have name by their function. Book also provides a lot of good reasons why is this important. I will provide one reason from testers perspective.

While I was testing one feature related with date calculation, I received following error:

I got error in method dup. So, instead of spending time to find out issue in my testing code or data, I had to first spend time to find out what is dup method doing. Exception was descriptive and that helped. The issue was with test data, I got null value from database. I found out on StackOverflow what does dup do. It is not easy to describe with simple name what does that method do. So I guess they agreed on some internal mnemonic. In Ruby code based that is used by millions.

Problem here is that Ruby codebase programers, by putting that simple name for method dup, put technical debt to Ruby codebase. Which could provide many different issues. When you hit hard problem, think how to solve it in proper way.

 

Comments are closed.


Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!