<linearGradient id="sl-pl-bubble-svg-grad01" linear-gradient(90deg, #ff8c59, #ffb37f 24%, #a3bf5f 49%, #7ca63a 75%, #527f32)
Loading ...

QA essentials

Your go-to quality assurance source

Testing Challenge – Clean Up My Code

“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”

― Martin Fowler

Martin Fowler said it all. It is easy to write code that machines understand. They don’t even read the code but the compiler is there to translate your code into machine language which computer understands. Now, people do not have compilers to help them with understanding bad code. We need to read it, use our brain to draw conclusions out of it and that is how we make sense from what we read. For me it is OK to write a working draft and then clean up my code as the last step of the process.

Don’t understand the code you’re reading?

What happens when we don’t understand what we read? Usually, it’s a feeling of confusion, frustration, despair, denial and anger, not necessarily in that order. In short, it’s a WTF moment. Someone wrote that the measure of good code is a number of WTF per minute. The lower number is better. So, the conclusion is: don’t do to others what you don’t want others to do to you. Write clean code and have it easily maintainable. I wrote down some of the advice for writing clean code although this is not all there is to know about it.

The challenge

Below is a code snippet written with all the possible anti best practice for coding. Review it, try to understand what it does and make a clean solution of it. It was written in Selenium with Java which should be widely used solution. The example shows small snippet of logging in to Demo Blaze website. If you want to, you can rewrite the clean version with a different programming language, Cypress, Playwright or any other tool you predominantly use.

clean up my code

A textual explanation of what should be changed and avoided will be sent in the next newsletter. Make sure you subscribe to my newsletter to get the advice.

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome content in your inbox, every month.

We don’t spam! We keep your data private and share it only with third parties that make this service possible. Read our privacy policy for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.