Dec. 6, 2016
Introduction:
Julia has more talent now after she attended her new school - stackexchange.com code review for code review on stackexchange.com. She did post two questions, and the first one, she learned a few things. One most important one is "Do not use abstract variable name. Do not let user guess what the variable name does".
Julia spent 30 minutes to review the practice in April 2016, and then, she went through the code, found the bug.
Last practice scoring 8 of 80:
(more than 1 hour, still having bugs, score 8.89/ wrong answer)
https://gist.github.com/jianminchen/57572227dafe939060f7cc81b193cd9b
Code review done by Julia on Dec. 6, 2016
1. Do not use abstract variable names. Please use meaningful name
line 16, s1
line 17, sA
line 20, T
line 22, arr
line 27, aA
In the function rotateArrayOneStepAntiClockwise
line 53, cnt
int 53, arr
line 71, ci
line 73, startR
line 74, startC
line 75, endR
line 76, endC
line 78, tmpVal
line 81, i
line 85, i,
line 89, i,
line 94, i,
2. function name should use
rotateArrayOneStepAntiClockwise
Should use PascalCased
RotateArrayOneStepAntiClockwise
"In C#, method names should be PascalCased, not camelCased"
Workout:
c# solution: pass all test cases
https://gist.github.com/jianminchen/6fabef7436097552e35633a549b0268a
Discussion:
Use meaningful variable name - The code is much easy to understand, therefore, static analysis should be much more easy.
For example, Julia reviewed the code on Dec. 6, 2016, line 53 cnt, the variable name is not meaningful, so she decided to replace the name using "steps". Line 114, there is some calculation, so in order to avoid timeout, there is actual steps taken < strip size. So, she decided to add a new variable name on line 114, called actualSteps. Just those two changes, Julia fixed the bug she could not fix in April, 2016 over 1 hour.
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment