Think

When we are coding we never forget to use our brain. Always ask ourselves. “Is there another way to do this?”, “What am I doing here?”. If we are copying someone else’s code. We need to understand purpose of the code well.

Look at the sample I choose for you and you will understand why I mean.

QuestionPage = QuestionPage.Replace("id=radiobutton_A", " id=radiobutton_A_" 
     & QuestionID & " onclick=ControlTEST(this.id.split('_')[2]); ")

This is very bad written ASP.NET web application VB.NET code-behind code. Besides repeating the same code, our developer is not aware of what the variables in the context are. Our programmer replacing id value with a new one and appending a javascript method call for onclick event. In that javascript call our programmer parses the control id with split and gets the id back and passes the Question id value to the javascript method. But forgets to “think” the value is already there and can be directly appended to the text.

And this is what I’m talking about:

QuestionPage = QuestionPage.Replace("id=radiobutton_A", " id=radiobutton_A_" 
    & QuestionID & " onclick=ControlTEST(" & QuestionID & "); ")

I like this quote: “This machine has no brain, use your own!”

Happy coding…

Posts created 141

Leave a Reply

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top