BASIC Programming
The Debate: "Long" Code vs. "Short" Code
Mr. Minich received the following two programming assignments for Ch3Prob5 (p. 105) from two very different students. He is in a quandary as to how to grade each piece of work. Obviously, the one student seems to be superflous and details "every little thing" in his code module. The other ambiguously compacts everything into one simple line of code. Discuss the pros and cons of each example and indicate what style you would prefer if you were a computer science teacher or professor. Include your name & class period with your answer:
"Short" Code
lblAverage = (Val(txtTest1) + Val(txtTest2) + Val(txtTest3)) / 3
"Long" Code
Dim TestScore1, TestScore2, TestScore 3 As Integer, Average as Single TestScore1 = Val(txtTestScore1.Text) TestScore2 = Val(txtTestScore2.Text) TestScore3 = Val(txtTestScore3.Text) Average = (TestScore1 + TestScore2 + TestScore3) / 3 lblAverage.Caption = Average
Ch. 3 Resources Page | Ch. 3 Programming Assignment | BASIC Programming Home Page