2
\$\begingroup\$

What is the way to provide large code for code review at the codereview.stackexchange.com?

I do my best cutting the code into pieces which could be reviewed separately as components. I started from low level in order to have generic components reviewed first before moving to higher components. The idea is that low level components mostly independent and we don't need to know the specifics of high-level task when we review them as long as functional specification complete and cover all the necessary aspects. Even in this case code could take more than 200 lines.

Nevertheless, reviews ask questions:

  1. What task you are trying to solve? Show it with real code.
  2. Show real high level code which provides the context of using these functions.

I see the logic in this, but in this case I should publish hundreds of lines of code, maybe even thousands, because high-level code in order to compile uses lots of low level modules. So, the code could be huge.

Meanwhile, reviews ask to put all code for review in the question, not on the links to other sources (godbolt, etc.).

Additionally some high level pieces of code could be project-specific or even client-specific and I could be not allowed to share it.

So, my question is, how should I publish large portion of code and how to handle such things.

I am quite sure the functional specification for my low-level code is comprehensive, most likely reviewers suspect that I am solving wrong task or do it in wrong way on high level if I have such functions on low level, but explanations in words are not enough.

I see their reasons, but can't find a proper balance and way to share large code.

Any suggestions?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$
  1. How to provide large code for code review?

    Even in this case code could take more than 200 lines.

    I see the logic in this, but in this case I should publish hundreds of lines of code, maybe even thousands, because high-level code in order to compile uses lots of low level modules. So, the code could be huge.

    The word "large" is extremely relative -- a "large" cat is smaller than a "small" adult. The same phenomenon exists with code too.

    • In the past we had a user who wrote an answer making a fuss about the length of things on Code Review. Ending the post with a quip about the moderately sized post being 'very large'.
    • Recently I wrote a relatively small project of ~1000 lines of code.

    What you think is "large" and what I, and likely other answerers on Code Review, think is "large" are likely somewhat different. As such I would suggest you only think of ~1000+ LOC as "large" for Code Review.

  2. I do my best cutting the code into pieces which could be reviewed separately as components. I started from low level in order to have generic components reviewed first before moving to higher components. The idea is that low level components mostly independent and we don't need to know the specifics of high-level task when we review them as long as functional specification complete and cover all the necessary aspects.

    Honestly, for large projects seems like a good idea, I have previously recommended a similar approach. However, the biggest drawback to the approach is by hiding context the reviews we give can greatly suffer:

    • If your high-level approach has an issue, we don't have the context to point out the issue, and
    • If the low-level approach includes some odd assumptions, not knowing the high-level approach can cause answerers to provide unhelpful reviews. In such situations the asker is annoyed at the answerer for not mind reading, and the answerer is annoyed at the asker for not including all the relevant details. In other words no-one is happy.

    As such, the approach is good if you know how to write good questions, but very bad if you don't.

  3. Meanwhile, reviews ask to put all code for review in the question, not on the links to other sources (godbolt, etc.).

    Additionally some high level pieces of code could be project-specific or even client-specific and I could be not allowed to share it.

    Our rules state you must include the relevant parts of the code. Asking for a review of a segment of a project is ok.

    Understanding the nuance of the situation is hard from a recount of the situation. As such, can you provide me with examples of users asking for all the code?

  4. I see their reasons, but can't find a proper balance and way to share large code.

    Lets look at your questions:

    1. 78 LOC -- Fast search for the longest repeating substrings in large text
    2. 76 LOC -- Fast search for the longest repeating substrings in large text (Rev.2)
    3. 129 LOC -- Fast search for the longest repeating substrings in large text (Rev.3)
    4. 42 LOC -- Incremental upper bound in sorted range
    5. 38 LOC -- Fast tolower function

    Lets now revisit the previous three bullet points:

    1. On Code Review ~75 LOC is not "large".
    2. Your projects don't seem large enough to need cutting up.
    3. Without reading each question too much, I wouldn't be surprised if you are not including all the relevant parts.

    Your questions also seem fairly low quality. You split up the already tiny code blocks and have tons of description. Your questions seem way too long for such little code.

\$\endgroup\$
11
  • \$\begingroup\$ Thank you for the detailed answer. Let me split answer to parts. (1) On the example, I wouldn't share (showing respect to the author), but you found the link yourself, so in case you can see comments under my answer I deleted here. The quote: "Also, "In my real code": we only review the code you post here, so if it is different from the code you actually wanted reviewed, you won't get a good answer here", well this is nuance or wording (to be continued...) \$\endgroup\$ Jan 27 at 0:20
  • \$\begingroup\$ (...continue), but I get this like a choice, either get "partial" or "not related" answers to post tons of code. Again, I totally agree with the author of the comment, I am just saying that this causes my question above. (2) Getting back to size, you lost me, I wrote that code size will grow significantly if I share all of it; it could take hundreds or thousands LoC. So, my questions was how should I share all the code. Am I got you correctly that I can share it on godbolt.org and post only low-level fragments in question? (to be continued...) \$\endgroup\$ Jan 27 at 0:24
  • \$\begingroup\$ (...continue). If so, it works for me except the last part in my question, what to do if it covers large part of customer-specific code which could be under NDA, etc.? (3) On you comment about quality of my questions, can I ask you to provide an example how they (or least some/one of them) could be reworked to high-quality question? Except ...(Rev3) question, which has a long story (of compiling it from parts) and could be shortened, I know this. What about the others? Can you, please, provide an example? \$\endgroup\$ Jan 27 at 0:27
  • \$\begingroup\$ @DamirTenishev (1) The comment isn't at all asking for all your code. The comment is for you to share your actual code. Please reread 2.2. (2) Post all your code in one code block on Code Review. Worrying about GitHub/godbolt and lots of formatting is a waste of your time and energy. Don't post questions involving code under NDA. (3) Try cutting 90% of the English description and only post one code block. (Remember all statistics are made up on the internet, 90% is an emphatic hyperbole) Look at programming-challenge as an example of how to go a tad to far in the opposite direction. \$\endgroup\$
    – Peilonrayz Mod
    Jan 27 at 0:42
  • \$\begingroup\$ Thank you for sharing your opinion, it helps, although still verges holy wars around "vision". Taking into account your reputation score at the site, I will take this as granted. On the items (1) I can't see the difference, although I understand what you mean. (2) I do, but reviewer provides comments which causes questions, answers, etc. from my side, so I need to put it somewhere. (3) This is funny every time; when I provide more information, people ask to remove it, later other people come and ask questions which were covered exactly be the removed text; this is opinion-based, again. \$\endgroup\$ Jan 27 at 1:03
  • \$\begingroup\$ (Side notes to be removed later): (a) (Just to be on the same page, is wasn't me who down voted your answer, so I am not the only person who considers it way too controversial.) (b) (Wouldn't "Your questions require additional work to be well-answered" be better than "Your questions also seem fairly low quality." to keep friendly environment here? I don't care about criticism, I just curios about your approach of collaboration.) \$\endgroup\$ Jan 27 at 1:09
  • 3
    \$\begingroup\$ @DamirTenishev There never was a downvote, your 'Rude or abuse' flag automatically applies a -1 to the score until it's cleared. While that sentence could be phrased differently, it does not cross into rude territory. People are trying to help here and sometimes direct language helps better than using roundabout language. \$\endgroup\$
    – Mast Mod
    Jan 27 at 10:45
  • \$\begingroup\$ @DamirTenishev "If I had more time, I would have written a shorter letter -- Blaise Pascal" is a timeless meme used by writers as a pseudo-apology for not taking the time to remove the cruft. As can be seen by CGP Grey. (2 & 3) You would need to show me examples for me to asses if you are being given conflicting advice. \$\endgroup\$
    – Peilonrayz Mod
    Jan 27 at 19:03
  • \$\begingroup\$ @Peilonrayz, thanks it helps. I knew that flagging will go to you as moderator to triage, so I just wanted to show my view on this here. Anyway, your and Mast's explanation here are comprehensive and make sense. Taking into account our argument on wording, let me ask to be patient here, did you mean "assess", not "asses" in the comment above? :) Anyway, I get your point and for now don't have questions, it works. \$\endgroup\$ Jan 28 at 14:14
  • \$\begingroup\$ @Peilonrayz, one request is still on the table if you could show how one (or more) of my code review requests could be improved (except "...(Rev3)" for the moment). \$\endgroup\$ Jan 28 at 14:47
  • \$\begingroup\$ @DamirTenishev Sorry, yes "assess" not "asses". \$\endgroup\$
    – Peilonrayz Mod
    Jan 28 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .