Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.
    d("rma_date") = request.form("FormDate")
d("rma_phone") = request.form("FormPhone")
d("rma_orderno") = request.form("FormOrderNumber")
d("rma_email") = request.form("FormEmail")
d("rma_partno") = request.form("partno")
d("rma_comment") = request.form("comment")
d("rma_note") = request.form("note")
d("rma_failtype") = request.form("failtype")

''' from this
dim handleTypeArray
handleTypeArray = Split(request.form("handletype"), ",")
Dim counter  
For counter = 0 To UBound(handleTypeArray)  
  if handleTypeArray(counter) <> " " then
    d("rma_handletype") = handleTypeArray(counter)
  end if 
Next
''' to this

d("rma_exchanged_partno") = request.form("exchanged_partno")
d("rma_account_number") = request.form("account_number")
d("rma_reg_number") = request.form("reg_number")
d("rma_error_description") = request.form("error_description")
d("rma_vareno") = request.form("varenumer[]")
d("sent") = true
'SoapCheckRMA(d)
  'd("rmano") = SoapCheckRMA(d)
  'test
  d("rmano") = "something else"
r = rendertemplate("templates\rma_new.done.html", d)
HandleRMANew=Translate(r, session("language"), "rma_new")

Should I refactor the code from the block from here to to here. Because I find myself too focusing in developing and create beautiful code. It takes too much time, since I should code more feature instead.

But I want a readable code so I can save bunch of time for me and another developers to work on this later. My goals of writing code is easy to read and maintain later. So what is the strategy in this case :

  1. Add a comment to explain what I do here
  2. Create a simple helper function to get the form value in one line like others above lines.
share|improve this question
I don't understand why you say it takes too much time to create beautiful code. I strive for clean code, and I can get things done as fast, if not faster than anybody else. Clean code makes coding easier and faster. – Jeff Vanzella Aug 16 '12 at 14:52
because normally I often spend too much time on creating beautiful code. I do search everywhere to find a good practice. Now I want to focus more on creating workable and ship it. Then I will refactor it later. Then I try to think about a good rules when to refactor the code so I don't have to think about it later :) – Billy Troll Aug 17 '12 at 16:07
I understand that...I fight with that problem at times too. Good luck! :) – Jeff Vanzella Aug 17 '12 at 16:18
Can you give me one advice on this ? – Billy Troll Aug 18 '12 at 18:05

1 Answer

up vote 0 down vote accepted

Yes, I would put it in a function with a meaningful name. That way, as you are reading through the code above, and you get to that line, you just say, "ok, now go off and do X" rather than trying to figure out what X is. If you need to know what X is, you go read the function.

As for your question on comments, comments used as you would like to use them are a code smell.

Read this post on comments, Or this post if you don't believe me

This:

d("rma_failtype") = request.form("failtype")

''' from this

ProcessRmaHandleType(d, request.form("handletype"))

''' to this

d("rma_exchanged_partno") = request.form("exchanged_partno")

reads a lot easier than the original, and honestly, it wouldn't of taken me any more time to write.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.