Scott Anderson
10/21/2021, 10:49 PMScott Anderson
10/21/2021, 10:50 PMScott Anderson
10/21/2021, 10:57 PMSrini K
10/21/2021, 11:07 PMKartik Agaram
If I write a comment like that my team probably will give in the code review a comment: write this doc on confluence (and no one never will read the doc).https://twitter.com/Welt_schmerz_/status/1451358249454800897
Kartik Agaram
Jimmy Miller
Konrad Hinsen
10/22/2021, 6:45 AMJack Rusher
10/22/2021, 7:12 AMChris Knott
10/22/2021, 12:35 PMKonrad Hinsen
10/22/2021, 12:55 PMScott Anderson
10/25/2021, 8:03 PMI am emphatically anti-external documentation. I think that is the single greatest way to make the documentation 1) not written 2) not read and 3) not helpful. External documentation means I have to know that I need to know something. When I’m reading code, why would I expect there to be something in a totally separate context telling me about this code?External documentation as done by most companies is often useless because it goes out of date even faster than comments. Ultimately if you want to do this right you have to have a documentation team, make documentation review part of code review, etc. Otherwise, in practice you're relying on arbitrary rules decided by coders in code review, or the converse, which is comment happy programmers that write too much. This doesn't mean external documentation has no value in the same way that saying comments are often useless doesn't mean comments have no value. This is somewhat equivalent to thinking automated testing will solve all quality issues and QA isn't necessary. Not all teams\companies can afford this of course, but it is the most reliable way to ensure quality if you need it. One thing is that many IDEs that programmers use day to day are lacking in documentation capability, which requires "cute" solutions like ascii diagrams above. Google docs is a significantly more powerful documentation editor than any IDE I know of out of the box. Generating more readable\searchable documentation from comment docstrings in code is pretty standard, so that approach arguably gives you the best of both worlds, but if you want to embed images\video, do more complex formatting, etc. most code editors are lacking.
riot_bridge
10/25/2021, 9:15 PMman
page for the token the cursor is currently on.)
It feels to me that it's going to be extremely difficult to provide enough context in comments for some things (a standard linux utility is a great example of this, where I may want to pull up the man page to review the various flags and their behavior, which is far too much for comment)Scott Anderson
10/25/2021, 9:29 PMScott Anderson
10/25/2021, 9:30 PMScott Anderson
10/25/2021, 9:36 PMKartik Agaram
Jimmy Miller
Ultimately if you want to do this right you have to have a documentation team, make documentation review part of code review etc. Otherwise in practice you are relying on arbitrary rules decided by coders in code review, or the converse which is comment happy programmers that write too much.Yeah, I’m not at all a fan of formalizing these processes. So your otherwise, rephrased, is exactly what I’d advocate for. Let each programmer decide how they want to comment things. Let peer social processes (not power relations) influence and change how that works over time. Uniformity in programming is vastly over-rated, in my view. If you have a comment happy programmer writing too much, talk them about it. I mostly find the opposite, code that makes no sense because of lack of comments. By makes no sense, I of course don’t mean I don’t know what the code in fact does. That is independent of the code. I instead don’t know why the code is doing what it is doing, or if what it is doing is what the programmer in fact wanted. If that person is no longer at the company, my job is now historical reconstruction. There may in fact be a good reason for the strange behavior the code has. External documentation doesn’t help here, or if it does it requires a lot more effort, because it is disconnected from the timeline of the system. Often times the key to why X works in way a1, is because Y worked in way b1 at time t-1 but no longer works that way. This is what external documentation fails to capture, it throws away these time relations, or obscures them at best.
Konrad Hinsen
11/07/2021, 8:47 AMThen there is the question of “inline” documentation vs non-inline. That of course is a distinction based on the interface we use. In an image based format, that can be configurable in a way text tools don’t traditionally expose.True in theory, but limited in practice, in my experience. Inline documentation (e.g. comments in code) is often written in such a way that it only makes sense in a given place. Example: "The two following lines initialize the frobnicators defined in class Foo."
Jimmy Miller
Scott Anderson
11/08/2021, 10:08 PMYeah, I’m not at all a fan of formalizing these processes. So your otherwise, rephrased, is exactly what I’d advocate for. Let each programmer decide how they want to comment things. Let peer social processes (not power relations) influence and change how that works over time. Uniformity in programming is vastly over-rated, in my view.I've heard this before and I disagree. I just came across some code where a programmer was just ranting in the comments about code quality. Not only was this low value, but it could be considered harmful or abusive to someone that wrote the code. I would have rather they refactor this code if it was bothering them, or worst case say "TODO: Refactor" or something than a multi-paragraph sarcastic rant. I've seen this a lot in code. This code was (theoretically) reviewed and approved. Do what you want anytime can lead to organizational issues, bullying, fighting in code reviews over what a "proper" commenting is. It's a lot of overhead and power dynamics come into play. I like to avoid this if possible
Scott Anderson
11/08/2021, 10:09 PMScott Anderson
11/08/2021, 10:11 PMScott Anderson
11/08/2021, 10:25 PMJimmy Miller
Jimmy Miller
Kartik Agaram
Konrad Hinsen
11/09/2021, 7:52 AMScott Anderson
11/09/2021, 7:21 PMScott Anderson
11/09/2021, 7:36 PMScott Anderson
11/09/2021, 9:08 PMScott Anderson
11/09/2021, 9:08 PMKartik Agaram
Scott Anderson
11/09/2021, 11:16 PMJimmy Miller
I think we have different definitions of formalization.Your definition is exactly what I’m talking about. I’ll start here with the meta point and get back to the code/comment standards more directly in a second.
This can come from top down, of course, but it can also come bottom up from individual members of the team. Large company wide coding standards should still accept feedback from individual ICs that bring up issues, and for things that are under-defined individual teams can define them for their codebase or use case if necessary... So, yes it sucks that you have had leadership that forced formal processes on you that didn’t work, but my experience has been the opposite, I’ve experienced more challenges with peer to peer interactions than with company or team wide process.What you are saying here is exactly how I’ve seen it done too. It has not been the case that leadership forced formal processes that didn’t work. They were all ICs who made these standards. But typically they were more senior engineers/architects. I’d imagine that is fairly standard. And it might sound crazy, but I think these are major problem. First, power isn’t about leadership or non-leadership. People can have power over you without being above you. The people who put these coding standards in place are deciding how you ought to work. Perhaps they are right, this standard is good, or at least good enough. But what does that matter? What problem are we trying to solve by forcing people to cohere to a certain standard? Are we trying to, stop that person who leaves rants in code? Are we trying to stop the annoying code reviewer who nitpicks every little thing? If so, those are great goals with a bad fix. Changing the rules isn’t fixing the problem. Those people still have those bad beliefs that cause them to want to have that behavior. If there is someone leaving rants in code that are disrespectful, shouldn’t some one talk to them? T.S. Eliot wrote some very poignant lines about this about people who
constantly try to escape
From the darkness outside and within
By dreaming of systems so perfect that no one will need to be good.We do precisely this constantly. Make system so that people don’t have to be virtuous. People don’t have to have informed opinions, they just have to follow the rules. I think this impulse is one of the ways we have stopped engineers from thinking. It is one of the ways we prevent people from taking rational approaches to their opinions on things like commenting. (And by rational, I mean a process that involves reasons, not that the outcome is correct. You can be rational while being completely wrong and vice versa.) Quickly skimming the c++ style guide you linked, it seems like a sensible set of advice. Nothing too objectionable there. If a team of peers wants to say, “we are going to try to follow this”, great! But what I see lacking there is why. For example:
Function comments should be written with an implied subject of This function and should start with the verb phrase; for example, “Opens the file”, rather than “Open the file”.I can imagine reasons why you might want to make this a rule. Let’s say you are making comments for some sdk to be used by the public, that seems like a sensible bit of consistency you might care about. But this style guide is completely void of that context, it gives no reason why at all. So, to summarize. I have no problem with linters. I have no problem with style guides. I have no problem with documenting code. I have trouble with imposition. It is more important to me that people come to considered, rational opinions. Imposition does not produce that. To highlight this, let me get back to the main topic more directly.
if one person is following a good practice, but the rest of the team isn’t, shouldn’t that be shared and adopted across the teamYes. It should definitely be adopted, but only if the team is convinced. Only if the team believes that this is the better way forward. Even if it is a fact that this practice is good, just adopting it by fiat does not accomplish my goals. Sidenote: I do like the commit message style of expressive documentation. I do that myself quite often. Even if I don’t know that people see it or not, it has helped clarify things for myself, even has helped me discover bugs. I’ll take a guess as to what the disagreement is here. I don’t think we’d actually disagree much in practice when it came time for code review. I’m not for long ranting comments. I’m not for nitpicking things. I try to stick with the standard formatting and styles of a community (depends on the language and code base). I agree that code review should transcend style and should “focus on architecture and the problem the code is solving”. What I think we are disagreeing on is he end goal. I really don’t care about productivity. I don’t care about efficiency. I don’t care about consistency. I care that programmers are getting to express themselves. That they are learning. That they are thinking through things. That they are building things that aren’t a pain for others. That they aren’t imposing on others. That they are grounded in the concrete situation of the codebase, the system, and the world around them. That they are building a theory (see Peter Naur’s Programming as Theory Building). These imposition of things like comment and coding style are admittedly small things. They are not a hill I die on. But to me the are emblematic of these larger issues.
Kartik Agaram
Scott Anderson
11/10/2021, 1:27 AMScott Anderson
11/10/2021, 1:28 AMScott Anderson
11/10/2021, 1:28 AMKartik Agaram
Scott Anderson
11/10/2021, 1:41 AMScott Anderson
11/10/2021, 1:41 AMKartik Agaram
Jimmy Miller