Almost Working code
Code Review is for working code. Let's play a what-if game... (devil's advocate) ... what if it's OK to have a rule that says: "Almost Working Code is on-topic".
- "I tried Poject Euler #3x and it is running really slow, and it gets the wrong prime factor for 654321234567, but here's the code, how can I improve it? It compiles!"
- "This code is part of my event bus system, and it normally works, but occasionally when there are many threads running, it does odd things. Can you think of ways to improve the code?"
Now, back to the current situation, no more hypotheticals ....
Purpose of a Code Review
The purpose of a good code review is a plural:
- Conformity and maintainability - does the code conform to the standards and expectations of your peers... will other people understand what you are doing?
- Performance and efficiency - are there ways to make the code go faster, or do what its doing more efficiently
- Are there edge cases that may cause the code to fail
- Is the code doing the right thing in the typical/normal case.
These items give a measure of confidence to a piece of code. This 'stamps' the code with an 'approved' blessing: The code will do what it is supposed to do, reasonable situations are covered, and it will do the job well, and will be maintainable.
But, what is most important? The most important item is the last item. Code that does not accomplish the normal task correctly. Without working code, the other items are pointless.
Now, about those questions that are "almost working"? What is the problem with them in Code Review? The problem is both simple, and challenging.
A good code review prioritizes the worst-offending parts of the code, you tackle the biggest problems first. You show where the most significant parts of the code are, and you then work outwards.
When you have code in front of you, the most pressing issue is always: does it work?
If it does not work, then it is useless. The only reasonable course of action for a decent code review is to say: "Well, let's start with the most significant issues, and that is the basic functionality. Once we get it working right, we can tackle the other issues, like indentation, overly-nested loops, etc. Maybe we can fix them all at the same time."
If the code is not working as designed, and the code review does not fix that issue, then having pretty code that does the wrong thing, fast, and efficiently, is not an improvement.
In other words, the most critical issue is: does the code work as designed?
The answer is no. The code is Almost Working, and that means the most important output from a code review would be working code.... and, guess what?
That issue is squarely the primary scope for Stack Overlflow.
If the code does not work as designed, then the only logical place where the question is on topic, is Stack Overflow. That will solve the most pressing problem. That will help the asker the most. That is the first step.
"Almost Working" questions/code does not belong on Code Review, it belongs on Stack Overflow.
- they are specifically on-topic there
- they are the immediate problem, and the remaining code review can happen after
- it is impossible to measure what "almost working" means.
- it is safe: A question on SO can be answered by the people on Code Review just as easily
- if Code Review people want to debug code they could spend time on Stack Overflow. In fact, many people do spend time on both sites.
- Stack Overflow is populated with people who want to do this. This it the purpose of Stack Overflow, and they want these questions.
- just because people on Code Review often invest more time in answering questions, and just because we have brilliant people who are willing to share their time, and knowledge, it does not mean that we are the right people/place to do the menial work... ;-)
- This is not a "no, your code cannot be reviewed" situation.... it is "... your code cannot be reviewed yet!". The asker is welcome to bring their code back when it works.
Yes, I am snobbish. I feel that the caliber of help that people get (and give) on Code Review is exceptional. Code Review is not only for trivial code, but for big and juicy things as well. We are not a first-line support system. We are third line people...
Stack Overflow is struggling with the workload of fixing issues. The truth is that Code Review could add significant help for those people who are struggling to get their code to work. We have very knowledgeable people, and experts in their fields. But, by inviting people to bring their code here when it's not quite working, it will be doing both Code Review, and Stack Overflow a disservice.
If you want to help people to get their code working, then the right choice is to spend more time on Stack Overflow, and help them with their issues (both the meta problems in SO, and the problems that people ask for help with).
When those people have working code, remember to recommend that they post it here!