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

Martin Fowler

And one from me

“With bad coders come’s a great mess”

me

Enough of quote game let’s

Start

Try reading the following code snippet

Did you get what’s happening here ? (Comment down)

Didnt get it ?

I am here to help

Ok,

So above is a simple method in java to compare if the email entered by user is present in database or not and if present the method return 1 else returns 0, Simple ?

The Problem

Now if you where to read this code after years (as i did while writing this blog) . Its might be difficult to understand what email and email1 variables refer too and what rs and stmt are ?

Also, if you were in a organization and left after writing this type of code it might be a headache for the next developer assigned to the project, to understand this code that you thought was perfect.

So lets refactor it

Refactor :- Restructure (the source code of an application or piece of software) so as to improve operation without altering functionality.

The Fix

The fix is simple we change the variables names to what they store as if we were speaking in natural language to some other person.

Is this more understandable now ?

Na na na dont say it i got you

Yes , it is more understandable .😎

And one more correction

Bye,

Thanks and regards

Fellow blogger

Hope above was helpful for writing a better code.

%d bloggers like this: