Hm. So I just give my opinion on code reviews by just giving explanation, link to a documentation, along with my recommended change.
My job is to ship software, and as an engineer/team lead it is my job to ensure the code we ship (<<< keyword) is maintainable, tested, and documented as far as any gotchas or hacks go. Ideally we want to improve the code base as well, especially when dealing with legacy code.
I think people take code reviews way too personally. Like, my priority is to ensure I don’t have headaches down the line and when I work with peers or more experience people, I barely leave any comments or get any on my PRs for them since we are all on the same wavelength and for the most part know what we are doing.
A junior engineer is a… junior engineer. They are going to have a lot of comments telling them how to write better code and a good suggestion will include a code suggestion and links to read.
It’s how they will get better, and for bigger tickets or super juniors, I sometimes pair with them to go through their ticket together.
At a certain level you just know how to identify patterns and understand how to build good software. You read books like Clean Architecture or Designing Data Intensive Applications to level up.
Juniors tend to just write yolo shit code or add more shit to a legacy shitcode repo instead of trying to improve it. They’ll add to the mess instead of writing a new clean layer on top to which we can easily maintain and modify. But that’s why you have to show them.
The only thing that helps people get better is time, being humble, and being genuinely interested themselves in becoming better at their craft. I remember my junior engineer days, and seeing my PRs filled with comments. But if I didn’t have those I don’t think I’d have leveled up so fast.
Your comment implies juniors are only juniors for a temporary amount of time. I've worked with many SWEs (some with years of FAANG experience) who consistently code like juniors. They are aware of things like the separation of concerns, but as soon as they run into a situation wheres its easier for them to leak one layer's concern into another they will do so. Consistently doing this over months erodes the quality of a codebase.
> They are aware of things like the separation of concerns, but as soon as they run into a situation wheres its easier for them to leak one layer's concern into another they will do so.
That says nothing without context.
If you want to move fast then it's ok to break things, and leaking layers is far from a non-negotiating tradeoff. Software is soft, and you can always revisit a piece of code to refactor it to suit someone's architectural tastes.
It makes no sense to criticize someone for focusing where it matters the most and actually deliver critical features without delay if the tradeoff is some legacy debt, and that by no mean implies they're junior.
One important skill of a senior is being able to keep their eyes on the prize and be smart about tradeoffs. Prioritizing subjective opinions over software architecture over delivering value is more in line with a junior way of thinking about software than not, and to me doesn't sound like a position to criticize others.
I'm gonna call bullshit on all of this. The time tax on not leaking layers in an application that doesn't already leak layers is nearly zero.
The problem is people don't want to expend the very minor extra amount of effort.
So you do it once. Then the next person does it because hey we already do it there so the code is not even subjectively worse, it's objectively the same, cuz you already crossed that line.
After a while you have a giant festering pile of shit that you just keep making bigger and bigger and now people are talking about rewriting it.
In my experience you start actively losing velocity in this situation very quickly. If you're doing this when you still your have 3+ months on a project, you're likely making poor decisions.
I'm not saying you need to constantly gold plate your architecture. But it should be palatable.
The subjective part is what is palatable. But I don't know anyone who thinks steaming turdpiles are palatable.
I mostly agree, BUT, it's very possible to end up with a situation where your current layers, even if they don't leak, are ill-designed for the feature you're working on. It can be a lot of work at that point to keep it non-leaking. You should still do it, but it won't be "nearly zero" cost.
In my experience, codebases never maintain their level of quality. Unless you are taking deliberate action to improve the codebase with every commit, it's actively getting worse like you described above.
The interesting thing is that this isn't a technical problem, it's a human problem. Most folks want to clock in, do their job and clock out, and going the extra mile to improve things isn't worth the effort.
I think its the same human tendency that leaves so much pee on the toilet floor - some humans will clean up their own, but almost none will clean up someone else's.
> Most folks want to clock in, do their job and clock out, and going the extra mile to improve things isn't worth the effort.
I suspect this is because it’s almost never rewarded. Either because nobody up the chain of command understands and values quality beyond “it’s working and making us money right now so it’s fine” and also because doing things right is tiring. Why should I spend energy on this and not have that energy when I’m off the clock if I’m not going to get more money/recognition/time off for it and I’ll probably get laid off or move on in a couple years anyway.
I don’t think anyone deliberately starts a job or task thinking they’ll do the absolute minimum. People generally want to do their best but the system moderates this desire and that’s the result.
I don’t really have a solution, just pointing it out.
And that's why you don't let any bullshit in, exercise eternal vigilance and rely on static analysis tools to stem the turd wave in an automatic fashion as much as you can.
> I'm gonna call bullshit on all of this. The time tax on not leaking layers in an application that doesn't already leak layers is nearly zero.
The time tax is paid by not delivering a feature. Architecture is supposed to be there to help you, not fail deadlines.
Also, it seems you completely failed to read or get what I wrote. My point was that if a PR delivers a feature without defects then your team is far better off if you accept the PR and refactor later when you can spare the time then it is if you throw a hissy fit and refuse to get the feature done if you don't get your way. You are paid to create value which is in delivering features and fixing bugs. Architecture is supposed to be there to help you.
Think about it for a second. If your architectural purity demands a hefty refactor, is that a good justification to postpone a bug fix or delivering a feature? No, it isn't.
> The problem is people don't want to expend the very minor extra amount of effort.
Except that most time it isn't minor.
You have to pass interfaces throughout a bunch of components, which require updating all sorts of tests, and result in a large code footprint.
> After a while you have a giant festering pile of shit (...)
That only happens if you're incompetent at your job and fail to do the most basic maintenance tasks in your code base.
Look at what you're trying to claim. It's supposedly easy and trouble-free to put together a PR that respects your personal notion of what the software architecture should be. Yet, the work to refactor code that breaks it is so insurmountable that you're no longer able to refactor it back to shape?
Which one is it then?
It looks like the FANG engineer you tried to badmouth had a firmer grasp on things and on what it matters the most than you do.
> The time tax is paid by not delivering a feature. Architecture is supposed to be there to help you, not fail deadlines.
Most deadlines are artificial. If it's not artificial, yeah, you're going to have to sacrifice something for the sake of the real deadline. But you are sacrificing something, and it's not just subjective fluff.
> Also, it seems you completely failed to read or get what I wrote. My point was that if a PR delivers a feature without defects then your team is far better off if you accept the PR and refactor later when you can spare the time
You don't ever have spare time. When you finish a feature there's another waiting for you. At least, that's how it works literally everywhere I've worked. Working this way is just another form of over-promising and under-delivering.
> then it is if you throw a hissy fit and refuse to get the feature done if you don't get your way
Rejecting a change doesn't mean you're throwing a hissy fit.
> You are paid to create value which is in delivering features and fixing bugs. Architecture is supposed to be there to help you.
It does help you. In the medium to longer term. In the short term, literally any standard out there will slow you down - unit tests, CI/CD, shit - testing at all. It all slows you down. It doesn't mean we should just code like its 90s era PHP - the fact that we don't should be a strong signal about the value of this whole hypothesis you have going here.
> You have to pass interfaces throughout a bunch of components, which require updating all sorts of tests, and result in a large code footprint.
Funny. Your tests are slowing you down, why don't you just comment them out to get your feature in?
> Look at what you're trying to claim. It's supposedly easy and trouble-free to put together a PR that respects your personal notion of what the software architecture should be.
It's not actually just personal. We have unit tests that enforce certain architectural rules.
> Yet, the work to refactor code that breaks it is so insurmountable that you're no longer able to refactor it back to shape?
If you don't do these things for the sake of feature velocity, as a senior software engineer, why should anyone else? If no one is, how large of a problem do you think you're going to get? And do you really think its just as easy to fix something after the fact?
Of course, if you don't know how something should be, that's one thing. But knowing how it should be and just skipping it altogether is quite another.
Why are you even refactoring for reasons you view as subjective? I don't do subjective refactorings. Despite what you claim, at the point of a change, much of this stuff is very not subjective. If you show any developer a function call before a feature was added, and what it looks like after its been hacked it in some fucked way, no one is going to say the fucked version is better.
> It looks like the FANG engineer you tried to badmouth had a firmer grasp on things and on what it matters the most than you do.
Well maybe you're just so smart its trivial for you to navigate this stuff. If so, continue by all means. Until then, us mere mortals will have to adopt standards so our codebases don't outpace our ability to understand it.
This possibly be true in some case, but I find it to mostly be wrong. The best time to fix up some code is when you are already modifying it, because that’s when you are already fully in context to understand the effects. Going back later to clean stuff up is much less likely, because you have to pay that marginal comprehension cost again and again for each issue you fix (and are less likely to even notice the problem). If you’re making this excuse, that suggests you have internalized that it’s ok to makes your codebase worse and you are probably degrading it progressively.
A 10k loc function is just a program wrapped in a function. I find it somewhat fun to refactor those. And you're god damn right I cannot deal with this eldritch horror you architecture astronauts come up with anymore, I'll take the dumb code please :-) YAGNI + KISS >>>>> SOLID all day every day
I don't. I like to feel productive instead of having to do laundry before getting to the actual work because someone just went ahead without any regard for quality control
>YAGNI + KISS > SOLID
Agreed
Monster architectures are monster architectures, and yet going from Enterprise(tm) architecture to chaos architecture so you can't know anything about the system without carefully going over hundreds of lines of code isn't any better
I've always had a pretty positive attitude towards code reviews (still a junior dev), because I know there's probably something I missed or a technique I'm not familiar with or some language quirk I didn't know about. If I submit a PR with a bunch of new functionality, I'm going to be way more concerned if I don't get a handful of comments on it than if I do.
Frankly I think everyone should have this attitude, seniors as well. (I try to) I am experienced but I know I write bugs and code that may be not as clear as it could be. We all do: we're only human.
Also depending on the codebase (and language to some degree), if someone senior writes a lot of overcomplex or abstract code that the rest of the team can't understand/maintain, that's just as much a problem as anything else.
> if someone senior writes a lot of overcomplex or abstract code
For me this is a much bigger concern than subtle changes to method names. My biggest headache digging into new codebases is when I run into layers and layers of abstraction that save 3 lines of code but force me to construct an entire mental map of the codebase before I can understand how anything works.
Any tips for giving feedback to senior people here? A lot of the complexity from abstraction is very hard to quantify and experienced people can have arguments that sound reasonable.
> Any tips for giving feedback to senior people here? A lot of the complexity from abstraction is very hard to quantify and experienced people can have arguments that sound reasonable.
Perhaps a starting point for this discussion is to point out that the DRY principle is nice and all, but there is also WET. Premature abstractions are bad code, a liability and hinder development. It's always better to have two independent but mostly similar codepaths than a strategy pattern with two concrete implementations. If it's cleaner to copy/paste a method and do some tweaks, do that instead. It's not like you can't refactor it when additional use cases emerge, and if they don't emerge then the abstraction wasn't needed to begin with.
Plenty of people believe that being senior is being clever with complex stuff. It isn't. Being senior is to know you don't need complex stuff, and be able to keep as simple as possible. Abstractions go against that.
Is the abstraction so that they can easily swap out pieces of the system without a single headache, or write effective tests, or to make it easy to operate in a soup of services? Because then it makes complete sense.
Like dependency injection is something that a lot of juniors struggle to understand. Or in larger applications DDD and all the crap that goes along with it.
There's a long list of things that I think are abused in an effort to save on some vaguely defined future cost that never seems to materialize. Some things off the top of my head:
* Interfaces(particularly in java) that have 1 implementation.
* Interfaces with many implementations but where each implementation is used in exactly 1 place.
* large inheritance hierarchies with generic type parameters. I'm sure there's a good use case for this but
it's usually a pain.
* Writing "generic" code in an effort to make something re-usable when in reality the code has knowledge of every location it is used in and tightly couples all implementations
I actually like the “one interface with one implementation” as it makes for less surprises.
With an interface I know that only that method can be called. If a class is passed in i have no idea what methods going to be used. It also gives me a better feeling that the coder has in mind what they need a parameter to do without worrying that they are going to rely on a couple of othogonal methods to be called.
The "death by a thousand abstractions" problem must be one of the most difficult ones to solve. Each abstraction in isolation makes sense and looks like an improvement, but given a few years, the overall code becomes an inscrutable mess of layers upon layers of complexity, hiding away what it actually does.
As a more senior dev who reviews junior prs all the time I hope they have the same view. I work with a lot of great people who seem to always want to get better, so I think they do. I only wish I had the same level of scrutiny when I was a junior!
I most recently worked on a 100% code-review team. Fabulous!
In my personal experience, the hump from wide-eyed novice junior to productive contributing member really doesn't take that long when every line that everyone writes is code-reviewed. The first couple of code reviews might take longer than usual. But it definitely takes much less time than it used to take to bring a junior up to speed. No net productivity in the first year used to be a rule, when bringing juniors onboard in the dark ages of computing. With 100% code reviews, that process seems to take no more than a couple of months -- maybe even as little as one month. The difference is dramatic.
And it's a fabulous way to transmit not only good culture, but also love of our craft.
> I think people take code reviews way too personally. Like, my priority is to ensure I don’t have headaches down the line
I feel this, and have personally experienced submitters taking feedback far too personally, to the point of even using sunken cost as justification of their design, completely overlooking valid points of feedback.
I’m looking for basics. Will it work? is the code clear? is it commented/documented? is the approach simple and maintainable?
Some submitters really need coaching on how to receive feedback, and how to plan their timelines to incorporate revisions.
Jerry Weinberg pitched the concept of 'egoless programming' [0] with the suggestion that it is possible to not take reviews of your code personally, with examples from his experience. Weinberg is careful to address the problem of feeling attacked by working on the social environment to avoid or limit attacks and the consequent defenses.
Thirty years later, egoless programming is one of Robert Glass's favorite fallacies in 'Facts and Fallacies of Software Engineering.'
IOW, it is a hard problem!
The SE research community has been looking into this for awhile (e.g. Greiler, Bacchelli)
[0] 'The Psychology of Computer Programming' (1971), Gerald Weinberg
[1] 'Facts and Fallacies of Software Engineering', Robert L. Glass
100% agree, code review should be there to check if the code doesn’t contain any obvious security risks or mistakes.
Designing features, architecture and learning should happen before someone even gets to the point of submitting a PR. Plus if it can be improved on in follow PRs then do that instead of blocking juniors with pedantics
Unless the submitter is stuck or asks for it, I avoid giving recommended changes on code reviews and instead just explain what (bad) consequences pieces of code have.
Providing recommendations takes away autonomy from the person who wants to contribute, and it's easy to end up glossing over the real consequences and ending up with "well, I would have done it this way" nit picking reviews.
I disagree with the title but found myself agreeing with many points in the article.
“Don’t be condescending” seems like generally applicable advice. But IMO, sometimes you just know something the code submitter doesn’t (or vise versa) and discussing that can be useful. And i think that’s pretty much teaching!
Yeah, and it doesn't take much to convey that this is a conversation between peers. A couple simple changes I get a lot of mileage out of. Where once I'd have written:
"Do [X]"
Now I write:
"I see [problem Y], consider making [change X] to improve it"
If the reviewee agrees then the change is easy and straightforward to make, but if they're unconvinced then the phrasing invites a dialog.
Or if I think I see a bug, I'll phrase it like:
"I think there's a bug here, how does this method behave if foo is null and bar is the empty string? I think we'd throw a null pointer error. Recommend adding a test for that case"
That's wisdom, and a clear way to make everyone around you better.
I'd add that being humble should also play a role. We have tastes and insights and preferences, and it's not productive to block PRs because of subjective, non-critical aspects. A working CICD pipeline lowers the cost of pushing a change, this we can always revisit things. It's far more important to have a team that trusts each other and feels confident to push changes fast than it is to have gatekeepers whose role ends up being one of needlessly putting breaks on a team for no justifiable reason.
Yeah, I think the title is a little provocative to get you to read, but I ended up agreeing with it. Maybe "don't try to be a teacher during code reviews" is slightly more precise?
Agreed, this isn't about teaching. It's about people who stroke their own egos when they should really be instructing. The example comment doesn't tell you anything useful except that the commenter might not understand what the author is trying to do. That has no call to action, no indication of a problem, and basically nothing useful to the author. It is a complete waste of time ...
The word "discussing" is doing a lot of work there and does nothing to distinguish it from condescension. Knowing something is one thing, being nice about it is quite another. Opposing them with a "but," like "hey that just goes with the territory," is not actually addressing the issue.
Isn’t that more “don’t give vague feedback” or even “don’t misdirect the reviewee”?
“I’m not sure if I understand the whole idea but could you explain what this method does?” misdirects by suggesting the reviewer thinks they need education, rather than that the reviewer thinks the code can be clearer.
I think it's more of the author having a misguided opinion of what teaching is. I've had a lot of good teachers in my upbringing but not one of them has ever thought that a vague/condescending question like "I’m not sure if I understand the whole idea but could you explain what this method does?" would be an effective teaching method.
Don't make teachers the punching bag for bad programmer code review. Programmers get paid 3-4x more, so if teachers can figure it out, then why can't programmers?
Good teachers teach you in the first place. The test part and telling you what you had done wrong comes later.
Meanwhile, teaching at code review means that student gets exercise, donit without guidance and then gets list of everything that was wrong with it. And then gets told that wherever his opinion preference differs from the reviewers one, he is wrong too.
I think the title wasnt totally clear but it's a totally valid use of the word. Its making the distinction between telling someone the answer and leading them to an answer.
Because to become teachers, you typically don’t have to have your ego brutalized jumping through irreverent hoops.
I mean going through engineering school and rigorous STEM degrees I can say that stuff is baked into the formula. You’re derided and dogged and gaslit from the onset.
Is it surprising these people graduate, become senior and perpetuate the mental unhealth?
> Because to become teachers, you typically don’t have to have your ego brutalized jumping through irreverent hoops.
No, instead you have your ego brutalized by spending half your youth (not to mention tens or even hundreds of thousands of dollars) getting an undergraduate and master's degree and teaching certification...only to receive poverty wages, pay for your own supplies, be abused by students and parents and administrators and HN commenters alike...
I was actually surprised when I looked up the pay bands for my old high-school and found that (head) teachers were earning near programmer salaries (this in Europe).
The ones who are currently teaching the kids right now?
Also, varies by country: the second world has "pedagogical universities/colleges" which are focused on producing school-level teachers in every subject taught in the schools — maths, chemistry, CS, you name it... and usually they have the lowest requirements compared to any other universities, so people apply there for a "last resort higher education" so to speak.
And then some people are bright enough to do well there, and some are not quite, and after graduation the smarter ones generally manage to find a better job than to be a school teacher while the dumber ones, well, they apply to schools to teach. And they get employed because schools almost always lack teachers. Yay...
It’s usually very transparent when someone is pulling this tactic so I like to cut to the chase by providing some token explanation. At the end I then ask “did you have any changes you would like to propose?” Tends not to happen again after that.
I've had instances of junior people who are simply not interested in learning and suffer from a massively inflated sense of ability and seniority, in practically every job. When reviewing code submitted by such people, "don't teach during code reviews" is actually good advice to the senior person. The senior person is saved the angst and futility of the effort. As a consequence, the other benefit of the code review, which is to catch bugs before they escape to the field, is lost as well.
For new people or junior people who have the right attitude, this is poor advice. Where else will people get habituated to the standards, preferred idioms and implementation quirks of the team/company/product/subsystem?
> I've had instances of junior people who are simply not interested in learning and suffer from a massively inflated sense of ability and seniority, in practically every job.
Standards documentation, code labs, pair programming, instructor-led group trainings. I agree that code review is a necessary piece of the puzzle, but there are other places for engineers to acclimate too.
Aside from the first, which is almost always out of date, the rest have been nonexistent at every company I have worked. And I do not even know what 'code labs' even means. My experience is fairly typical SV stuff, so I am wondering where these companies that still do all these things are.
Perfection need not be the enemy of good enough. Usually, whether the documentation is out of date or not, _some_ documentation is better than none. I've rarely come across an instance where documentation was actively harmful -- not to say those cases don't exist on the margins.
> And I do not even know what 'code labs' even means.
Code labs are self-guided lessons, like a tutorial, about the systems and technologies that your company is built on. They're called code labs because producing code/artifacts as part of your learning is one of the goals. For example, your company may have a custom enterprise installation process that's built upon Ansible, Terraform, AWS tooling, and a little proprietary work sprinkled on top. Some code labs may take you step-by-step through how to add a new service; configure, migrate, and wire up databases; etc. such that you'd have working code at the end of the code lab and new knowledge around the company's best practices.
Similarly you can do this for the standard language at your company. Most companies accumulate some amount of proprietary helpers, libraries, or frameworks in their standard language. A code lab can walk you through how to write code in the way your company expects using the helpers, libraries, and frameworks that are common across your teams.
> My experience is fairly typical SV stuff, so I am wondering where these companies that still do all these things are.
I have over a decade of similar experience across startups and large companies in NYC, Seattle, and SV. In the last 5 companies I've been at, all of them have had some combination of the above.
In case the author is around, please consider removing the email capture popup. It not only interrupted my reading of the article before getting to the main point if it - it had an animation that literally startled me, and I immediately closed the site. I can't believe I got jump scared by an ad in an article but it was incredibly offensive.
Yeah the high-contrast aspect (very dark background overlay and bright white animating block) makes it especially startling! That was pretty nuts. I also immediately closed the page, even though I wasn't done scanning/critiquing the content.
Seriously, I read the first sentences and got so distracted from the pop up. Wtf is that animation? The close button way too high (on iOS), so I had to scroll up again and then I had to search where I left off. I just closed the tab instead.
There’s no link to the original medium article but I have a feeling the author was female or some other minority in the industry. I might be totally off base with that though. I agree that the wording is very cringy, but if I may offer one defence: I also learned to do this sometimes because otherwise juniors wouldn’t listen to me at all. You had to make them think it was their own idea or they were magnanimously granting you, an idiot (notice how they apologise for being slow), a rename to help your tiny brain understand. Otherwise you’d be stuck in an insane week-long code review with the junior furiously dismissing every single instruction until you looped in a coworker with more social power. I see this article is also by a woman and I’m happy that she’s in an environment where she doesn’t have to do that. I don’t think the other article’s wording is praise-worthy but I do think it’s a somewhat rational adaptation to an environment of hostile coworkers where you need to make yourself submissive to get anything done.
Clear and concise is often received as short and terse. I personally think people as a whole need to learn to receive communications better, versus expecting the author of said communication to know how to tailor their message for your individual preferences. So the whole premise of this article is focusing on the wrong side of things in my mind.
It’s similar to the idea of “being offended” which is pretty common these days. It’s been said that offense is taken not given. So the reader is usually the problem. Ignoring of course the blatantly offensive topics and communications, which do still exists. But in a work situation, you should always approach things with an assumption the other person is trying to be constructive and make an effort to not be offended by something that initially offends you or was delivered in a terse manner. If a patterns presents itself, have a conversation and ask why it’s being delivered that way.
I mean these days people take offense when you link them to the documentation or propose a better way to do something. They have too much pride to accept that they might not be hot shit.
I've had people tell me they think its insane how some people can't handle code reviews and would go to their manager about it.
Great article, I like the thought here. I've fallen for this myself, trying to "teach by asking questions", but in reality just come off as patronizing or disrespectful to your counterparty. That kind of thing is a lot more suited for a discussion where it's legitimately important that someone come to the conclusion for themselves (eg, a political argument). A code review is different, both parties already have an implicit obligation to be receptive and open to feedback. You can be direct, and talk somewhere else about the "grand lesson" if you want.
There is a balance to be found between pointing out what is going to cause problems and what you find personally inelegant. What I find personally inelegant I typically leave as a suggestion, while approving the MR as a whole. The contributor - who has spent more time than me thinking about his code in the context of the issue - can finish things up on their own, taking my feedback into account where they see fit. This works well for most people. Very junior developers or those new to the team/tooling might need more explicit guidance on more mundane matters, so I will be more stringent on those matters, at least for the first few tickets.
If I have a serious concern I will also message/talk to the person directly. We need to reach an agreement going forwards, rather than trying to "play the game" and slip code past each other's standards. Direct communication creates good relationships and honest intentions between developers.
MRs can be a good opportunity to publically ariculate design decisions and trade offs. In that sense, they are good for learning. Small, well-defined, succinct issues/MRs can be an invaluable form of documentation, helping you to reconcile bugs with expected behaviour months or even years down the line.
I think it's important to keep MRs fast. The more friction there is to merging work, the less likely developers are to break up and integrate their work in clean, intelligible, atomic commits.
Pretty much any language has linters or even automatic formatters to handle stuff like this. If people are inclined to be opinionated on these subjects, better just to let a program handle it and leave it out of the reviews.
s/teach/be petty/. Nobody cares about a method name and if I care, I can send my own cleanup change later instead of holding up work of others. A good compromise is to approve and still suggest a different name in comment and then trust competence of my coworkers to decide for themselves.
On the other hand, if someone is loading images on a main thread of a UI app, teaching is a primary priority compared to getting the change merged. Obviously they are misunderstanding big parts of platform they are developing for and, until I get them up to speed, they will have a hard time being productive. So even if it takes an extra week, it's important that they learn the best practices and how to apply these in specific cases.
I am absolutely against mind games like asking vague questions and holding up work until the author gives me my preferred answer, neither of us have time for that.
Yeah, totally agreed. My general principle on method names is: suggest an alternative, but it's a purely-optional suggestion. Sometimes I can think of a far more effective name for something, and I'll suggest it, but say "not required, just suggesting". There are a ton of things in code reviews that could be improvements, but are also not a big deal, or quite subjective. Then there are the things that seriously affect code quality and future maintainability, which would be the kind of thing that should hold up the review until improved or corrected. In either case, being completely clear and straightforward is always a solid approach. Asking weird rhetorical questions (as opposed to clear and direct questions) does not help the process and generally elicits uncertainty and self-doubt in the code submitter.
A misleading method name can cause serious screw ups down the line. At best, they make reading through the code later much more confusing. It's not petty to ask for accurate and comprehensible method names.
The problem here is the mind games. If you think a method name is a problem, just say so. Don't hint and waste people's time and energy. Just say what you mean. (If you can't do that, you're in a terribly unhealthy work environment, and fixing that should be a top priority.)
I think the example is too contrived. Like you said, make a non blocking comment about the name and be done.
For less trivial examples, oftentimes I think honestly asking "why did you do it this way?" Before making a suggestion is a good idea. Often we dont have the same context nor know the intention.
Emphasis on "honestly." If you just want them to do something differently then suggest that directly.
Considering context is helpful also. Like perhaps they implemented some function in an odd way because other similar functions in the existing library are also that way.
I agree with the everything the author says in this article. But their advice includes teaching during code reviews, so the title is misleading. Explaining the 'why' of a code review comment is teaching, nothing wrong with that IMO.
When one reviews another person's PR, it's as if you are reviewing your own. This is not a mere superficial verbiage; a few times, I'll review someone else's code, and actually block on small modifications and comment on them asking for more details, only to discover that the small change was to something I myself wrote and I forgot it so deeply as for it to appear entirely new. As one is kind to oneself often, one needs to be kind to the others, and trust them. It starts from there, and you co-learn and re-learn (which I think is a subtle point in the article), since whether you wrote it or them, it does not matter.
I really resonated with the way you frame it. For me it's absolutely key that ego doesn't get in the way of teaching/learning and the quest for improvement. People need to feel safe so they don't feel bad about having their output critiqued in front of co-workers. They should relish in it! Teaching is a gift! We're all perpetually learning, forgetting and making mistakes. The enemy is the idea that we need to maintain an image of getting things right all the time.
> I’m not sure if I understand the whole idea but could you explain what this method does?
What's wrong with this? The author suggests that this is somehow extremely condescending, and that the reviewer should instead review at an "eye-to-eye level". So the solution is to jump to a remedy without fully understanding what the writer meant?
If you are going to review at an eye-to-eye level, then you have to go in assuming best intentions. A method might seem poorly named, but if you're reviewing a peer then it is very likely that you just doesn't understand some context. I'd never jump in and assume a method is poorly named unless I understand why it was named that way: Chesterton's Fence.
I agree. And it can be good to rephrase your opinion into a question sometimes. You may think it should be done differently but it's good to know the reasoning behind things.
But if it's the simple renaming example then by all means lead with the suggestion.
I do not know what happens. Do reviewer really cannot understand, or he is trying Socrates on me? Or maybe he have some undisclosed anxiety issues, and keep himself vague on purpose, because he is afraid to show me some inner processes of his mind? Maybe it is an imposter syndrome at work or something like that?
What should I do in such a situation? Should I answer his question in a direct way and to explain what is happening, or should I jump to a meta and try to guess why the reviewer asking me such question? I mean I need to go meta and to untangle all this mess, but I'm a programmer, not a psychologist. This is not a psychotherapy session. But I'm forced to imagine all the kinds of mind states to find those that may generate the question I've got, and then to find some reaction for me, that will do minimum damage regardless of the state and give me more information about the state. So my reaction will be a counter question. It is time spent for a small talk, with me carefully moving around to not trigger possible anxieties of the reviewer, while being unsure about his mental issues and not knowing what exactly I'm trying to avoid.
But the honest review when reviewer gives me his thoughts is much more informative. I need no more to guess what is going on. “I had a hard time grasping what the method does. What about changing the method name to openRequest() to make the methods objective clearer and improve code readability?” gives me all I need to proceed in a conversation. I know what reviewer wants from me (to change method name), and I know why he thinks so. I know my options: I can accept his change, reject it, or propose some third variant of the method name.
> I'd never jump in and assume a method is poorly named unless I understand why it was named that way: Chesterton's Fence.
Review process is not a process of editing wikipedia. My commit was not approved yet, I'm not a random anonymous person from Internet, and the reviewer also is not a random anonymous person. So Chesterton Fence is not applicable here.
If I think that my way to name method is better for some reason, I'll inform the reviewer on my opinion, and my reasons to think so. Moreover I can move the conversation one step further right now by addressing his concerns.
This comment is perfect and elicited the long-buried inner rage I used to feel towards a former staff in an old company. I should not have had to navigate a staff engineer’s mind minefield like my BPD ex. Additionally, a person with that degree of influence should not hate directness and potential conflict more than he hates himself
What's wrong with it is that the reviewer knows well what the method does. The reviewer just wants the name to be changed to reflect that. He's just playing dumb, perpetrating the Socratic method to guide the reviewee to the conclusion/agreement that the method needs a different name, through the giant detour of having to explain what it does, when both parties already know that.
The question itself would be fine if the asker were actually interested in the answer. What's condescending is asking the question while already knowing the answer, with the unstated ulterior motive of getting the writer to change the method name.
How you develop people using code reviews depends on the person you're developing. How you ensure quality code depends on who's submitting the code. A lot of people aren't receptive to feedback or change requests until you make them think through the issue a bit more. It's imprudent to make hard and fast rules about code review etiquette, but a lot of the suggestions here count as useful guidance to consider.
As a manager, it drives me crazy when some feature doesn't make it into the sprint because some "senior engineer" decides that this is the time to teach a junior/intermediate the proper way to do something with a long drawn out "teaching process" via PR comments.
it's especially galling if the original PR was working, reasonably well written, no major flaws and they forced the junior to rewrite because it wasn't "best practices".
Some of the comments here seem more like sabotaging junior developers career by drawing out how long it takes them to get through code reviews than teaching them anything.
"A feature not making it into a sprint" is your problem. You will get in trouble for that, it will make you look bad in front of your boss, etc. "Not following best practices" is not your problem. If the code turns into a mess, it's not you who will have to deal with the consequences, at least not you directly. As a manager you will demand that your senior developers fix that (while still shipping features, of course). After all, that's what expected of senior developers. So, the incentives for you and for your senior engineers are not aligned.
Of course I don't know if that's even remotely close to your reasoning. I don't know you or your project or your priorities, I have no idea what "best practices" we're talking about and how reasonable it is to follow or not follow them in a given situation. I might be totally wrong, you may have all the right reasons to be mad about those reviews. But the comment makes it sound like your senior engineers are idiots who block PRs for no reason, and that can't be good for your team.
> "A feature not making it into a sprint" is your problem. You will get in trouble for that, it will make you look bad in front of your boss, etc. "Not following best practices" is not your problem.
Hmm, almost like this concept of “sprints” is unhelpful.
It’s rare that delaying a PR by 24 hours to get it right has any relevance to business outcomes, in fact it is often better for everyone in the long run.
But with artificial deadlines and fake metrics imposed by scrum, when this happens managers will often freak out because something didn’t “make it into the sprint,” or an engineer’s velocity dropped.
Yep. At this point "scrum" (or "daily standups", but that's a separate issue), "sprints", or "burndown charts" are all run-for-the-hills red flags to hear about when chatting with companies, IMO. It shows a lean towards process for the sake of process, artificial deadlines and artificially subdividing work to fit within said deadlines, and sometimes a "we do this because everyone else does, without questioning it" cargo-cult mentality that often extends into the tech itself.
There's exceptions, clearly. And the process does work for some folks. I'm glad those people are happy. It has rarely worked for me, or for teams I've been on.
> it's especially gauling if the original PR was working, reasonably well written, no major flaws [...] wasn't "best practices".
You see a clear dichotomy between well written code and what your senior engieers see as enforceable best practices.
I'd guess you also see half of the time your team spends on coding as some useless nitpicking you're letting them get away with by sheer generousity or bcause you don't have a choice...From the looks of it that can't be a healthy team dynamic
> You see a clear dichotomy between well written code and what your senior engieers see as enforceable best practices.
No, in general, I agree with code review comments my senior developers make. I'm talking about the difference between "best practices" and actual best practices or in the difference between "this works, but next time, a better architecture would be x, let's refactor next time we come back to this" and "I'm blowing up the sprint"
“this works, but next time, a better architecture would be x, let's refactor next time we come back to this”
In my experience there is rarely ever a “next time” and “fix it later” becomes “fix it never”. It’s always cheapest to fix worst practices up front rather than letting them metastasize into a huge pile of technical debt later. It’s also rare to find anybody interested in or willing to go back and fix old stuff when priorities often involve chasing the next shiny thing.
Exactly - this, coupled with phrases like "blowing up the sprint," suggests that nobody on this team is likely to trust that the offer of "fixing it later, next time" will be held to.
Comments such as “blowing up the sprint” suggest a habit of catastrophizing because an artificial deadline wasn’t met, that’s not going to serve you or your teams well in the long run.
When I hear comments like this from managers it’s generally a sign that I need to start planning an exit strategy.
edit: Also, “my senior developers?” They’re human beings, not your property, dude
Honestly it sounds like a terrible place to work. There’s artificial deadlines with no slack for error, and Junior devs are unable to learn to allow them to be better in the future.
As a manager, the Junior shouldn’t be on the critical path solo. That’s just bad management.
> the difference between "best practices" and actual best practices
hmm...this would sound so much better if you felt your team was pushing for "actual" best practices.
Perhaps it's all working well, but from your words there's so much underlying tension and your clarification adds further distanciation between you and your team.
I'd hate to be on either side of this to be honest.
> There are better places, and ways, to teach junior developers than long, painful code review processes.
If I had to choose the best single way to grow as a software engineer, it would be through code reviews: both giving and receiving.
That said, "long, painful" code reviews is a red flag for your team. A code review should have one of four outcomes:
1. Lgtm.
2. Approved. Left some suggestions for your consideration.
3. Specific changes requested.
4. This whole approach needs to be re-evaluated, let's talk.
_None_ of those should be long or painful. It sounds like your team might be doing #4 in the PR itself when really that's an exceptional case that should make it to a usually-synchronous discussion.
I just strongly disagree with this. The context of a code review is the perfect opportunity to teach, much like a technical design review is for system designs, and having them sit as an observer during an incident response is for triage/debugging a live system under stress. There are no better settings for teaching these skills to juniors. And you should really let your senior engineers take advantage of these times to impart their wisdom. It will help them grow junior engineers into high quality seniors that will help make your team’s output better and faster in the long run.
> The context of a code review is the perfect opportunity to teach
I think we are just talking about different scales and different senior developers. Every code review is either teaching something, finding missed bugs, find better ways to do things that a senior developer makes full use of.
If not, your code review is just a preformative waste of time.
I'm talking about simple PRs, the kind I would assign to a junior developer, that are actually finished, getting held up while a "teachable moment" unfolds.
But "simple PRs" with poor implementations compound over time and make for outsized tech debt in the future. I agree that addressing specific major issues within the PR (e.g. comments) is not a good approach. If there are "enough" (for some relatively subjective definition of that) "teachable" things, it's likely an in-person (or at least chat thread) conversation is warranted. Under normal circumstances (and I'd hope a junior engineer isn't making a PR to patch something for an emergency/incident resolution), a PR should be fine to hold up, as the release timeline should account for the fact that junior engineers will have longer PR cycles.
Code review is the most common arena for getting feedback on my code. My team doesn't pair very often, though I think that's more effective. I don't believe I have other opportunities for it...?
If you're getting complete rearchitecture feedback in a code review, something's wrong because that's too late for it. Especially if it means rewriting later changes they haven't put up yet.
The wrong part happened when sender went to work on something alone for a long time then sent a giant PR all at ones instead of progressive set of changes. Don’t blame the reviewer for having to either compromise their integrity by letting it slide into the codebase or getting onto the likes of TP’s shitlist by putting their foot down.
Like what? What's that Confucius saying: "I hear and I forget, I see and I remember, I do and I understand"? Nothing beats teaching using a real example that the parties are hands on with.
I get what you're saying. Delaying a milestone to have a long convo in a CR is not good prioritization. But as the technical manager it's on you to budget more time for junior devs to land their changes.
On the other hand, some people actually write stuff that isn't great but visually seems ok. You have the senior engineer to say 'no lets not create a mess'
At least I think so because of your previous comment. Since I can only take this as context their might be a misunderstanding. Still I would like to point out a few thinks, I did not like about your comment.
In my opinion, you are looking at the problem from the wrong angle.
If code gets worse (non working) after a code review, the reviewer made some serious mistakes and/or was not guiding his colleague to the correct solution like it should be.
Also if working code gets rejected because of bad practice, you should not be mad about it but be thankful that someone caught that before release.
If your only measurement of code quality, is that something is working, I would consider that a dangerous practice.
(I'm Not OP) - At the end of the day we're all trying to strike a balance between shipping fast and keeping technical debt down. Asking juniors to only ship code that's good as what a senior would write is very rarely the right balance point. Senior engineers must learn to understand when code is "good enough". If you're a senior and you haven't developed this skill you're bringing your team down.
Concretely, a heuristic I rely on is to understand whether the sub-par code being added "infects" the code base e.g. it changes an important interface, it adds a poorly designed interface other code will rely on etc. These are the places its important to put your foot down. Conversely, if the internals of a one-off function or class could be a little cleaner... eh, ship it.
> Senior engineers must learn to understand when code is "good enough". If you're a senior and you haven't developed this skill you're bringing your team down.
> If your only measurement of code quality, is that something is working, I would consider that a dangerous practice.
I'm really confused as to why there are so many people assuming I don't give a shit about quality when I have CODE REVIEWS.
Why are you assuming I want them all to just be rubber stamps?
And what God Complex do you have to have that you assume the "senior developer" is ALWAYS in the right, and the junior and the "non-technical" manager just don't respect "quality" at all?
Your comments are very reminiscent of non-technical managers I've known - they often have a very shortsighted view of the value of code reviews, because they don't need to work on the code.
'It works - why don't we just merge it? Keep velocity high!'
A code review is exactly where it's worth spending time making sure: the code is maintainable, doesn't degrade the quality of the repo, and above all teaches the junior things they can use next time to do a better job faster.
Spending some time using a review as a teaching experience pays so many dividends later. People who don't touch the code don't understand that.
Of course, there's a level of 'good enough' a senior should be able to identify and approve. But the bar should be high.
Your and some of the other comments I've read are very reminiscent of some of the worst senior developers I've worked with, because they treat code reviews as a way of molding the code base to their own personal expectations rather than improving it especially when a junior engineer finds fault in their code. They waste time using code reviews as a teaching exercise that gives bad habits to junior developers that need to be broken later.
Why? His comment was the perfect description of what a senior developer should do during a code review.
Code reviews between a senior and junior are teaching exercises and always should be. It is critical and a fundamental step for juniors to be become more experienced.
As already written by the comment you replied to, the right balance has to be found, but this is part of the job description if you call yourself a senior developer.
> I'm really confused as to why there are so many people assuming I don't give a shit about quality when I have CODE REVIEWS.
Because code reviews are a minimum. This is like saying "Why are there so many people assuming I don't give a shit about driving safety, I put on my seatbelt!" Yeah, it's because you're driving rashly and putting others at risk. Just putting on a seatbelt isn't the be-all and end-all of the process.
If you want to know, the reason that people are assuming you don't give a shit about quality are your sprint-centric attitude, your putting the word 'senior engineer' in double quotes, and the talk about "well if the PR was working then it should ship".
This gives off an impression of someone who doesn't understand at a fundamental level that the process of code reviews and have the contribute to learning on the team is is what makes for quality in the long run, not just the mere fact of having them.
Of course, it's quite possible you are the reasonable party here and your senior engineers are curmudgeons. In that case, have you tried talking to them about it? What did they say? Your complaint here seems to indicate that this hasn't happened yet.
Given a senior developer, a junior developer, and a non-technical manager, in the context of a code review, the vast majority of the time you should absolutely listen to the senior developer.
If that's not true in your organization, then hiring, leveling, and leadership should all be questioned.
Is it? Their comment might come from having worked at companies where code reviews aren't even a thing, let alone source control. It's crazy out there, especially if you're nowhere near Silicon Valley.
If you don't want to see that drawn out at code review time, then have the juniors consult with the seniors prior to that stage. If you don't want seniors holding juniors to standards then do away with the junior/senior title separation because it might be meaningless to you.
If I thought the junior was not up to the task I assigned them, I would have had them consult with a senior developer during the task.
I'm literally talking about the case where a senior developer decides that this task was not implemented to their personal standards AND makes it a "teaching moment" that means it doesn't get delivered this sprint.
Saying "this can't ship without significant rework" is something that needs to get escalated, not ground out in a code review.
I'm an engineering manager with a coding background 12 years coding, 3 years managing, and "assigned as task" throws a red flag for me. I believe we should be (a) understanding what preferences and skills each engineers have (b) have a conversation on how they can best make impact using these (always comprises, sometimes a project just needs to be done and they're the only one free, but by that not being the norm, they don't mind), and (c) setting a goal for them to achieve (rather than a "task"). E.g. expose an internal REST endpoint providing these parameters with this latency and scale by two weeks, and letting them determine the tasks needed to get there. (obv this goal should be set together as well, not dictated).
> E.g. expose an internal REST endpoint providing these parameters with this latency and scale by two weeks, and letting them determine the tasks needed to get there.
The pile on is interesting. Apparently I’m a terrible, non-technical, micromanager who believes I own my staff and working for me would be a horror show. All because I’ve said some senior engineers go to far in code reviews.
"It works" is the most common metric I've seen juniors decide when to submit code (the rest being just trash). Add code review to that and expect it to get merged because "it works"? Not sure the problem is with the code review holding up the ship...
Ironically, I think the people responding to and freaking out about your response proves the OPs point, that many engineers treat PRs as an exercise in ego stroking rather than reinforcing software design.
When I was a junior engineer, nothing annoyed me more than engineers trying to 'teach' during code reviews and doing so in one of two ways:
1. Being vague and unhelpful under the guise of having me 'figure it out'. They would point to a spot and say 'This needs fixing, rework this', without saying how to rework it other than to figure it out. Eventually I would need to drag them into a call to get them to tell me how they personally wanted it fixed up. Often times the way they wanted it fixed was incorrect because they misunderstood the work or were just wrong.
2. Giving incredibly bad 'improvements' to the code. Things like 'change X loop style to Y loop style' where Y doesn't affect the readability or performance of the code, or things just for the sake of adding comments.
So nowadays when I do PRs for juniors and such I try to have direct, actionable comments with rationale and room for disagreement, or if something needs to be reworked I try to assess why they did it that way and do a quick call/discussion with them. Junior engineers are generally not dumb and too many seniors treat them as such.
I agree to some extent. Personally, I do spend the time to teach in PRs but also approve the PR to unblock unless there's much needed changes. It unblocks people, and you quickly see if they cared about your comments if they follow up with another PR addressing them.
It works in reverse too, when you’re the one being reviewed and you receive feedback you disagree with.
Instead of dying on the hill and delaying your merge, just implement the feedback and then argue. You can make your point while still accommodating your teammate and moving things along.
(Obviously, this practice shouldn’t apply to feedback which is truly bad)
This author, and 99% of anybody writing about, and large majority of anybody attempting to do code reviews misses that there are two very distinct and not particularly compatible purposes of code reviews. IMO the only really important one is identifying code that doesn't do what it's supposed to, either because the author miswrote it or misunderstood the requirement. Critically this is just "what", not how or why. This is often really simple stuff, like getting a sign wrong or storing a value to the wrong field/variable or using && instead of ||. 100% objective stuff. The other purpose I'd more broadly describe as "design review", which is focusing on "how" the code should have been written. In my experience this is mostly subjective and that's what consumes all the time. My suggested approach is to officially delineate the two, and whenever someone raises design or style issues in a code review just say "that sounds like a good topic for the design review". You can actually use PRs for both purposes, just front load the "design review" during the WIP phase for a feature branch, and then do the "code review" before merging into a mainline.
Real world example: a company I consulted for a couple years ago had a lead architect known for nit-picking code issues with junior devs ad nauseam (to the point where potential hires were told to expect it and not join if they didn't think they could take it). Their production system was brought to their knees by a doubled for loop, literally just a duplicated line of code. This code copied messages from one place to another, but almost all of their testing used cardinality 1 so it didn't affect the tests. In production all it took was a couple cardinality 2 cases because there was one edge case flow that could route copied messages back through the loop and this caused cascading failures as 2 became 4, 4 became 16, etc. This error would have been obvious to anybody reviewing the code, even if they didn't really know much about it, but as that module was written by said architect no one else felt qualified to review it.
Sounds like someone trying promotion driven development, instead of doing their job (<<<<<<<) effectively.
Code reviews are important, but I think I know the type of person you are talking about which takes these things to an extreme and ends up being dead weight. Often times, they're not as good as they think either, just being honest.
You need to rein in these people ASAP, honestly they are the worst kind of coworkers. Toxic positivity and wasting time/effort 99% of the time. We're paid for our skills, and one of those skills is being able to figure things out on our own or ask for help with pertinent questions. This hand holding crap to get eyes on you is just silly and something I really dislike working at big corp.
I’ve always thought if it’s a “teaching moment” that it makes more sense to just pair with the engineer and go through it together. Otherwise it’s a really long turnaround to go back and forth in PR comments that just frustrates all parties.
Depending on what you're pointing at, it might be better to let the other party take whatever time they need to digest your comments and adjust (including comming up with counter points)
For instance if you're telling them about a behavior defined in a RFC, it can have better long lasting impact if they get the time to read and understand it on their own, than if you're over their shoulder shoving info at them.
Basically, live teaching requires you to be good at reading the other person's state and providing the relevant info in a digestible way, while they live code. It can work, but that's a high bar to pass.
This is more prevalent than one thinks, particularly at large companies where senior developers will ruthlessly put roadblocks, either as a way of carrying out group politics, or keeping control over things where the risk of a new idea or paradigm exceeds the possible downsides, however minor, of rocking the boat.
However, if this is in a small team, then it's a management problem that needs to be solved by the people manager. Either the hiring process is not eliminating bad performers or people with bad attitudes, or team dynamics have deteriorated considerably.
From the senior's viewpoint, though, if they are going to be held solely responsible for janitorial work to avert juniors' substandard work blowing up down the road, or picking up the pieces when that does happen, then it makes perfect sense for the senior to put up roadblocks, junior dev's career be damned. Again, this is likely a management problem where people are not held accountable and made to maintain systems they come up with (tenure is so short, especially among junior people, that this is likely to be a systemic problem).
Do you talk about your “senior engineers” this way to their faces? Using scare quotes to refer to the titles of your colleagues? Do you refer to them as minions too?
You sound like an absolutely insufferable person to work under.
Agreed. Too many "senior engineers" fail to recognize when they are simply venting their territorialism by nitpicking in code reviews. The role of a good manager is to restrain these tendencies.
You have to fight to produce quality and you have to do it continuously. You cannot just merge in "working(tm) but not using best practices" and then turn on the quality-switch months or years later.
Your attitude is creating a culture where nobody cares and it's why many good engineers end up hating their job.
Wow. You sure are extrapolating a lot about me from a simple comment.
While we're extrapolating, are you the type that makes junior developers rewrite their loops as list comprehensions or the type that makes them rewrite their list comprehensions as loops? Because I've seen both in code reviews.
I think that these kind of reviews can potentially be squashed by building consensus around what kind of feedback is right for PRs, what conventions you agree upon using, etc. Far too often, these kind of "best practices" only exist in the senior's head (if they're even truly best practices at all), so it becomes a very frustrating moving target for a junior.
I agree you should push back against this as a manager, but it can be hard to do so tactfully from my experiences. You either have to say, "no," or engage in protracted debates on subjective ideas around readability and maintainability.
> I agree you should push back against this as a manager, but it can be hard to do so tactfully from my experiences.
Just review this thread ... it can be utterly painful. There are at least as many senior devs who don't like to take feedback on how to deliver feedback as junior devs who don't like to take feedback.
One problem is software developers losing sight of business goals. The business questions include: What's the cost of that code merging as is. What's the cost of the merge being delayed and the feature not being shipped. What are the different options that we can pursue to maximize the value of the business. This is going to be my problem or someone else's problem is not the way to make good decisions.
There is not going to be one answer for every situation. Let's say your startup runs out of money tomorrow, the feature must be demo'd today to raise more money, is this code getting merged or debated? If this software for a life support system the bar is set very differently. What's the cost of failures, what's the cost of future maintenance, etc. - all matters.
If the senior engineer has enough projects/years under his belt, good judgment, has seen various business outcomes, and can weigh this, then I would generally trust them as being closest to the decision point. If those are the senior engineers on your team I don't think code reviews and mentoring juniors is going to be a problem.
Sounds awfully micromanagey, making the decision as someone with way less context than the senior engineer… unless you have OCD and non-pragmatic engineers upholding unreasonable expectations.
List comprehensions are advised against in Google’s official Python Style Guide and many similar guidelines for this exact reason. You sound like a micromanager who thinks he’s more technical than you actually are
> While we're extrapolating, are you the type that makes junior developers rewrite their loops as list comprehensions or the type that makes them rewrite their list comprehensions as loops? Because I've seen both in code reviews.
One of them is right, because a codebase that consistently uses one or the other is better than a codebase that mixes the two. If the team hasn't made and communicated a decision then that sounds like a management failing.
(list comprehensions are the actual right thing to use, for the record, but that's far less important than having a standard and sticking to it)
That doesn't really seem like the sort of thing that needs to be standardized at all, though. They're both valid, they're both readable to anyone competent, just do whatever feels right.
I don't think it does. This isn't some big architectural thing where the choice actually has implications that reach beyond the function you're in. It's not even on the level of naming conventions, where you might have to go look elsewhere to see how something is named. If you can understand both of them, which you should be able to even as a junior (as you even imply yourself, by saying it doesn't matter which one you pick), you can read both of them just fine.
> It's not even on the level of naming conventions, where you might have to go look elsewhere to see how something is named.
It's similar to naming conventions - you wouldn't want to mix snake_case and camelCase in the same code - only more so, because it's a bigger leap from one to another. Things that are the same should look the same and things that are different should look different. If each loop in your program is represented differently, it'll be hard to understand.
> If you can understand both of them, which you should be able to even as a junior (as you even imply yourself, by saying it doesn't matter which one you pick)
Juniors can learn anything but they can't learn everything. The more trivia they have to deal with, the longer it will take to learn the big things. It doesn't matter in the same way that, say, it doesn't matter whether you pick Rails/Ruby or Python/Django for your webapp; it's still a bad idea to do both at the same time.
The vast majority of questions around quality that end up surfacing in code reviews can be much more easily settled by commonly shared tooling that enforces organizational style and security practices. Leaving "best practice" up to the code review stage just ends up allowing senior engineers to demand code that they themselves would write, not what's best for an organization.
This is the worst time to try to fix anything. The author has just finished (or thinks he finished) the work and any attempt to change anything by the reviewer is going to elicit resentment in most people. Try to tell the person the change cannot pass and you can make an enemy. Or you let the change in because you like the person. Either way, it is bad.
And all this for naught because in my experience the law of sunken cost comes into action and people will try to push it as much as possible unless it really has a critical flaw.
For this and other reasons I prefer pair programming as an alternative to code reviews. Work progresses faster when two people do it (vs slower when one has to finish it and then another review it). You actually have two people understanding what happened. And you can avoid all of the drama because problems get fixed as the solution is being designed and written.
And yes, this is a good (or at least better) time to teach. Though I try to not be preachy and instead prefer to demonstrate how I solve problems and comment on why.
Anyone who resents code review isn't fit for this business. This is exactly why information given by interviewers to hiring committees focuses on the nature of the back-and-forth exchange during the interview, and decidedly not on whether the candidate completed the exercise. The most important feature of a software engineer is how well they fit into organizations.
Same above goes for anyone who believes they have "finished the work" before getting any reviews.
Ever joined a team and needed to get results from them? Usually firing every single person and starting to hire for your high standards is not an option.
There is your idealised view of how software development should work and then there is the real world. I prefer to stay grounded in the real world and figure out actual ways to help people succeed rather than telling them how they should be performing and firing if they can't meet my standard.
Whatever you think about what people "should be feeling", the truth is when they made their last commit almost everybody feels they finished their work and when it is thrown back to them they do not welcome it. I have never seen a hiring process able to only pass people who are happy to get review comments requiring them to review large part of their work.
After quarter of century as a developer with 1/3rd of this time in pair programming teams I can say that's not true.
Works goes faster when you work with another person even if for the fact it is harder to procrastinate.
And problems are always easier and cheaper to solve the earlier in the process they are caught.
Then there is the simple fact that a well executed coding review will take significant portion of the time it took to make the change. Most coding reviews are really only cheaper because the reviewer is just skimming the code to see for obvious faults. So it is not really apples to apples comparison.
to the yearslong experience I have improving and optimizing code review processes at Microsoft and beyond.
Sorry, but that's not a brag. Quite the contrary, actually.
On the topic of code reviews, I think the style varies so greatly between teams that it's hard to generalise. I've had teams where the others were very eager to learn and ones where they'd rather not.
> " do you think we could rename this method to openRequest() or something along those lines?"
> I find the fact one person actively makes the other person “think”, extremely condescending
The only thing I learned from this and the other example given in the blogpost is that some stranger named Greiler thinks that "teacher" means "person who tries to be kind."
The message might work better if it were reframed as "code review feedback should be direct and succinct."
I tend to agree with all of the principles here, with some caveats.
What if you find yourself giving so much direct feedback that you're basically rewriting the code via comments, time and time again?
Feedback or instruction that's not super direct has its place - we have to foster independence somehow. If I'm in a lead position, I have to be able to ask you to go work on a bug or think about something on your own, even if I could probably figure out an answer in a short period of time myself.
Trust must always be in the room in order to ask someone to work, whether it's in code review or elsewhere. If that trust is not there, more direct feedback/instruction can help rebuild trust, but it is not the end-all-be-all.
To tie this directly to the example: there may be points where I don't give a suggested name or solution in my comment simply because I haven't thought of one, and the reviewee may need to be able to accept that without them thinking I'm being passive aggressive. (I would do my best to communicate that context in those instances.)
I’m with you. If I don’t think a chunk of code is readable, I’m not going to rewrite it all for them off the bat. I’ll just say that it’s not clear and could probably use some cleaning up. And they can either push back, or do something on their own, or ask if I have anything in mind, or seethe silently and ignore me. If it’s complicated or seems like they’re struggling then I’ll ask if they want to pair on a solution.
Otherwise it’s kind of like - “why didn’t you just do this yourself if you had something so specific in mind?”
This works better if you both are in roughly the same time zone. It's not so great when you have to play "guess what the reviewer wants" with one day of latency between iterations of the review.
I believe she had a good intention but her idea is not good at all.
The Socratic Method is a fantastic way to trigger a health conversation about a topic without forcing a "senior" idea over a "junior".
In my experience, asking someone to explain their intention behind a piece of code is a good way to:
1) Help the individual validate that the code is communicating their intentions
2) Discover if there is an different angle that the individual is not considering
3) Discover that the individual has actually produced a "good enough" quality and a risk/benefit analysis can be made with more information.
Alan Kay spent the early part of his career explaining his ideas via The Socratic Method [1]. How, he spends his career yelling at us for failing to come to his conclusions.
What, exactly, is wrong with "I think the current name of this function fails to encapsulate what it does. I think openRequest() would be a better name."
[1] At least, that's how it comes across when reading a lot of his articles.
Using the Socratic method is being direct. It's directly showing the junior what their thought process should entail when they're writing code. I don't ask these questions because I get off on sounding superior, or want them to play guessing games. I ask these questions because they're the questions I ask myself when it's my work, and part of my job is demonstrating how they should approach their tasks.
On the flip side, try not to be the kind of person who can't be taught at every moment.
Like when I was a dev and a senior was reviewing my code - I really wanted to know how and why they thought so I could learn, and I made that known.
Emotions and defensiveness are a thing and you can't change how open someone else is, but to the extent that you can keep yourself as open to and welcoming/soliciting of feedback, the faster you grow.
The author's example doesn't work. It's too retrospective.
> “I had a hard time grasping what the method does. What about changing the method name to openRequest() to make the methods objective clearer and improve code readability?”
That suggestion requires grasping what the method does.
In the original article the feedback is given after the submitter had explained.
The whole main short-term, medium-term and long-term points of code reviews is to teach. Teaching is a gift. It doesn't mean you have to slow things down but it's always a gift. Anything implying otherwise negates the experience of previous engineers helping even if it seems "difficult" and takes extra time.
Here’s a list of practices I call mindful code reviews. You shouldn’t unnecessarily extend the loop, but you also shouldn’t rush or auto approve. https://max.engineer/mindful-code-reviews
I hate, hate code reviews. Seems to attract crazy people.
An example:
My old boss did a code review on my code and sent ALL CHANGES via chat. Not instructions, code. "Please do it". I did. And in the reassessment he hated the code I wrote, which was his. He publicly cursed me out on the review tool. It is written for anyone to read years later.
He considered himself an excellent code reviewer.
I've never worked with the author of the article, but the line "I'm not sure I understand the whole idea, but could you explain what this method does?" Remember my old boss. It started like that... and the next few days were a review hell.
At the end of the day, since we’re talking about a human relationship between two individuals, it depends what you can and can’t do. In my opinion, do whatever you have to do to express your talent vicariously by completing your work to whatever standards matters most to the company you work for. Individuals can do whatever they want in code reviews. My advice is conduct yourself as the author says with humility and strict purpose. Teach, don’t teach, Who cares? Like, seriously. Jr devs, think for yourselves. So many snakes out here, watch your back. That’s the advice you should be getting sometimes.
100% agree with this, especially the part about slowing down code reviews. Don’t be condescending but give your opinion directly, asking if it makes sense. I personally like “what do you think about renaming this… was thinking because…”
It's saying don't be roundabout trying to play teacher in code reviews and other stuff. IMO code reviews often drag on longer than they ought to, so be direct and clear offering additional clarification az needed. Sometime even use Slack or video meet if that clears things up quicker and only record the outcome on the review.
Respect people and their time. Also be open to sugestions and for reviewers not every suggestion is a must, make clear which ones are.
> Today’s one is about how (not) to “teach” during code reviews.
> It’s not bad to “teach” in code reviews, but it should happen on an eye-to-eye level.
> But first, let me show you how I’d phrase the feedback for this example:
> “I had a hard time grasping what the method does. What about changing the method name to openRequest() to make the methods objective clearer and improve code readability?”
So the headline is just wrong, it's about not being a dick or vague when writing code reviews.
It all depends on who the parties are, their relationship to one another, their relative knowledge of the tech stack, application and problem domain, and the nature of the code being reviewed itself.
Your reviewing style should ideally be tailored to the above contexts. Conversely, if you use the same exact process everywhere, you’re probably doing it wrong.
This is correct, except the ones between new team member and their mentor during onboarding. Those are specifically designed to give newbie all small ifs and buts we never put into written documentation. But at this time no one expects perfect velocity on those tasks.
Often when reviewing a change I will frame my feedback in the form of a question, not because I am trying to be a Socratic jackass but because I'm not sure. Only a fool thinks they are an expert on C++ so when I say something like "does this const-qualified variable declaration in namespace scope necessarily imply internal linkage?" it's because I want to know, not because I already know. And if it's not clear to me, it also won't be clear to the next person who reads it.
I do like some of this author's articles on code review but I think they emphasize too little that the author of the change is not one of the interested parties in the review. The review is the opportunity for the organization to defend the interests of future maintainers of the code. The interests of the person proposing the change are a distant second and they should be ready and able to either advocate for their decisions or acquiesce to requests for changes.
Not to mention when my mind comes up with the logic to solve a coding problem, it’s absolutely not in a format that lends itself to explaining to another human
So now you’re making me sit and “look stupid” because I have to actually parse out in human language why I think the way I think, meaning I have to sit and reason out why I did something
It has something to do with "making the person realize the problem by themselves", because some people get offended if you directly tell them "do Y because it's better", but I completely agree the way is being done there is not effective.
I have a manager who does the "teaching" thing poorly. If you're making a request in the form of a question, fine. But if you're trying to make me THINK, fuck off.
Clickbait title but I generally agree being direct in code reviews is great especially if it reduces the feedback loop & doesn’t drag out the code review process.
Not sure if I agree with this. Maybe because at my place the culture is much more direct. It's more about what u r 'teaching'. If u r right and proposing a better solution and u back up with evidences ppl r more than happy to consider ur comments. If u r proposing something like an alternative, then that's not a teaching and would turn into the discussion.
There is no playing such games in our code review. Saves everyone's time and directs to the points
I’m not sure if I understand what this article has to do with teaching?.. Oh, I get it now, sorry for being slow! Do you think we could rename it to "Don't be an asshole and lie about (not) understanding things" or something along those lines? :)
PS. But, titles aside, do we actually want to do teaching during code reviews? There are many activities when teaching and doing are better kept separate (like, you don't want to teach your partner how to dance while you're dancing). Do code reviews fall into this category? Should we consider them a doing phase or a teaching phase?..
A good friend of my wife once did this to me at a wedding. She had started a pair dancing hobby maybe six months earlier and was very enthusiastic about it. When I asked her to dance, I didn’t mean I wanted a lesson. It was so out of sync with my expectations that I left with barely an excuse in the middle of the song.
I just remembered I did recently ask someone to teach me a dance ("just off" the social floor), but 1) it was in a crowded bar just off the dance floor so it's less in the way than the onlookers 2) it is a notoriously easy dance 3) she knew I was good at dance 4) I picked it up in 45 seconds 5) we immediately went on to the dance floor and finished the song together with no further instruction.
> Should we consider them a doing phase or a teaching phase?
Yes.
Expert intuition is a tacit skill one can only learn on the job. By getting feedback from an expert in real-time. It cannot be done as a separate exercise. There have to be real stakes and the work has to be real.
You wouldn’t expect a surgeon to not get feedback during their first surgery would you? But you also wouldn’t want them to cut somebody open just for learning in the absence of a medical need.
We even call this “supervised learning” when a computer is doing it.
> Don't be an asshole and lie about (not) understanding things
This is quite common in teaching, and assessment, to the point that some people think it's synonymous with teaching. It really isn't a good way of teaching, and I gather that modern teacher training teaches you not to do it. https://betsysneller.github.io/pdfs/Labov1966-Rabbit.pdf
> He tells me that the teachers had already decided that many of the school children didn't have any language at all: they didn't know English and they didn't know Chamorro. When he asked them how they knew that, they described the very same kind of testing procedure that I have observed and reported in mainland schools. […]
> The children's response to this test, in general, was to say as little as possible. […] James is one of the most talkative children in the group. Others said much less. Some were paralyzed into silence by the request for display: […] To all these questions, Eunice presented a stubborn resistance. Finally, she produced a minimal response to the teacher's verbal bludgeoning: […] The teacher-tester is a pleasant person when you meet her face-to-face as an adult. […]
> A third characteristic of adults' talk to children is deliberate and obvious lying. The teacher-testers frequently try to force answers to known-answer questions by claiming that they don't know things which they plainly do. As the children follow the strategy of saying as little as possible to stay out of trouble, they frequently answer with "Uh-huh" or a shake of the head. The teacher could simply point out that the tape recorder wouldn't pick that up. But instead she says, "I don't know what uh-huh means."
---
In fact, the author's preferred code review:
> “I had a hard time grasping what the method does. What about changing the method name to openRequest() to make the methods objective clearer and improve code readability?”
is a much better lesson than the "teaching attempt" it replaces. I would call teaching the primary purpose of code review, with the resulting codebase improvements a useful (but necessary) side-effect. The alternative, of just silently fixing the code, is worse because it doesn't stop the same mistakes being made again.
I use junior engineers’ code review submissions as an opportunity to teach, and any senior engineer who doesn’t is committing professional malpractice. They have to learn, and that requires someone (in the case of a code review) to teach them. One can do it without being condescending, though
The Socratic method for teaching is actually quite good, and it can be employed without condescension.
> The Socratic method for teaching is actually quite good, and it can be employed without condescension.
Socratic Method is hard to use without coming off as patronizing, even if you think you're being careful.
If you're genuinely jumping in to ask real questions to understand the problem, that's great.
Most of the time when I see people use Socratic Method in the workplace it's because they think they're doing the other person a favor by asking leading questions instead of communicating directly. For the person on the receiving end, it becomes a game of navigating the questions and delivering the answers you know the person wants to hear, all done as delicately as possible to avoid disturbing their sense of superiority.
Once you start doing this, every question starts to feel like a loaded question. Is this person genuinely asking my thoughts, or is this question another test to see if I agree with their secret answer? Am I okay to express a differing opinion here, or will I trigger another round of patronizing questions if I give the wrong answer? Is this person asking questions because they don't know, or because they think they know better than me and want me to realize I'm wrong?
It's almost always better to approach the conversation as a discussion between peers. If you go in with implied seniority structures or student/teacher methods (including Socratic method) then it stops being a conversation among peers and starts to feel like another social hierarchy game that must be carefully navigated to avoid upsetting your elders.
Just talk to your coworkers like collaborative peers, even if they're more junior than you. If you want to communicate something, say it directly. Don't ask questions and try to get the other person to guess the secret answer you want.
Yeah ; I'm super open to coaching as opposed to mentoring, but last few years, when my managers tried to employ the coaching / questions methodology, it was obvious and painful : they did not feel like open questions to discover something together ; they felt like fake questions that had a "right" or rather "expected" answer, so it did not feel at all like "me figuring things out for myself " but rather"me trying to guess what I'm expected to say". Typically after a few frustrating minutes I just ask for straight feedback - I am happy and excited to receive constructive feedback and lecturing.
My boss and I had an open discussion and it may be they just need more practice - coaching is a skill like any other and just because you took a two day class doesn't mean you're an expert yet. So we accepted that while he's more experienced than I am and my mentor in many things, he's junior in "coaching" so we sure working on it together :-)
I had some college professors who used Socratic style in class and I enjoyed it. However, that was literally a teacher/student relationship that I signed up for. Furthermore, the professors were usually genuinely curious about my responses and wanted to explore them when they didn't necessarily agree with the expected answers.
In the workplace, Socratic method just feels like an unnecessary power move. Someone is trying to cement their role as teacher and the other person as student.
I had a manager who liked to use the Socratic method for everything. He communicated everything in the form of questions. If you gave the "wrong" answer, he'd give a sharp sigh and then rephrase the question, giving you another change to give a "better" answer.
This method was mildly annoying when he was right, but it was completely disastrous when he was wrong. He'd often arrive late to a situation that people had been dealing with for months and assume he knew exactly what was going on, better so than the people involved. He'd start his Socratic questioning, but you weren't allowed to explain the context or how you arrived at a solution. Your only option was to navigate his Socratic questioning until you could gingerly explain that he was missing a key constraint, or that we had already tried that, or that he had received bad information, and so on. It became a tool for him to control the conversation and put you in your place at the same time.
It was a very sad time in my career. I'd arrive to every meeting feeling like I was about to play a psychological game of "guess the right answer" as I navigated the Socratic questions until we could get him to reveal what he was really thinking, or why he was so frustrated, or why he thought we were wrong, or any other number of issues that he just wouldn't tell us.
+1 I gave up on the "teaching" years ago, it never did anyone any good and wasted a lot of time.
Now I say explicitly what I think is wrong and what needs changing.
This too can come off badly so I limit reviews to one or two remarks. I also build a relationship with these engineers and explicitly explain how I do reviews different nothing that while I give you solid direction, whether you take my advice is entirely up to you to evaluate and that it is 100% ok with me if you explain why I'm wrong and you're not changing it. - the purpose of my reviews is to catch problems you haven't thought of, if you've already thought about it and made a trade off that's your call to make. (And I trust you to make it)
Translation: I'm too old for this tit for tat shit and have bigger hills to die on than where you put your whitespace.
I should also clarify that I am always clear on exactly why I am suggesting something, and the level of importance I place on the change (though usually, if I'm commenting, it's relatively important, if not, I just don't bother mentioning it)
I think there's value in having a small set of 'goto questions' or maybe rules that are well known and regularly used. Then you can go over them together in the case of a review, a debugging session or to clear up a problem.
I don't know how that relates to the Socratic method. But I think it's useful, if done honestly. It's like a little ritual that you do together and it serves both sides as a guideline in the moment, but also helps to converge to a common way of communicating things and writing code.
> The Socratic method for teaching is actually quite good, and it can be employed without condescension.
I seriously doubt a PR is the right medium for the Socratic method, or that trying to employ it in that venue can sound anything other than condescending.
PRs are the end result of the developer's work to address an issue. Communication through a PR is asynchronous and inefficient wrt time. Engaging in gratuitous chatter in PRs actively blocks the developer from delivering his work. Pushing for needless iterations with cryptic open-ended questions where you force a developer to be on the defensive reads as if you're standing in the way while gratuitously questioning someone's ability in a very public way through a medium designed to persist discussions til the end of time.
If a PR has an issue just do the right thing and go straight to the point. If you feel the need to get into what you feel are teachable moments, reach out to the developer through your choice of direct chat.
I think the real problem here is that because everything is going online-only, we're falling into the trap of making everything public and recorded forever.
Maybe I'm just too damn old, but I don't like this trend.
When code reviews were in person, as a senior person, I could deliver feedback without that feedback becoming a public albatross stuck around someone's neck. We all screw up and miss things. Sometimes we don't write the best code. Sometimes we don't know something that should be universal knowledge.
My correcting your mistake or lack of knowledge shouldn't get recorded for all to see.
With the way things currently are, I now have to do two code reviews. One to correct actual problems and teach/mentor and the other for the public checkin to the system codebase.
I’ve written plenty of bad code before, and some of it was released and some of that led to tricky bugs. I don’t feel particularly ashamed of having written bad code though. Maybe I’m thinking of a different kind of feedback? Like, hopefully the worst problems can be figured out before much code is written, and if someone made some asshole critical comment, I would probably consider it reflecting poorly on them rather than me (indeed I find the permanent record of the comments I left and since regretted weighs more heavily than the record of the comments received – or the poor code committed). But I guess different people react to feedback differently, especially critical feedback and maybe you’re imagining some kind of ‘the whole thing is totally wrong and terrible’ discussion? But that feels to me like a case where a bunch of blame belongs to whatever allowed a bunch of totally wrong code to begin to be written.
Emails that have a long list of CCs suddenly become a political hothouse of "If I say X in front of Y it will seem like a criticism and they will clam up and then the whole thing becomes something the "positional authority" has to adjudicate not an experience led discussion"
I feel that this problem is the very reason FOSS mailing lists (ie Linux) were so brutal - it's that or you risk lack of clarity.
I know I sound like someone complaining about woke snowflakes, but there is a line somewhere around here and I wish I knew where it was
>When code reviews were in person, as a senior person, I could deliver feedback without that feedback becoming a public albatross stuck around someone's neck. We all screw up and miss things. Sometimes we don't write the best code. Sometimes we don't know something that should be universal knowledge.
Heh, I actually ran into a funny situation because of permanence of code review.
One time I was onboarding a new employee (call him Bob) to how pull requests worked in GitHub, and I wrote up a sample one from his computer. Just to be silly, and because I didn't realize the implications, I said "okay and you fill out the body, describing what you did. As an example, let me just put in some filler text, 'hey, you people suck'."[1]
I was planning to delete the obvious-garbage PR, but I didn't realize ... GitHub doesn't let you delete PRs, only close them! And it triggers emails!
Mercifully, no one said anything. But then months later, another co-worker (call him Charlie) was venting to me about what he didn't like about Bob: "And, another thing, one time, that asshole wrote up this pull request, where he said, hey, you people suck!"
So I owned up: "Oh, uh, Charlie, that ... was actually me. I was writing a dummy pull request to onboard Bob but sent it by accident."
Then Charlie said, "Well ... he's still an asshole!"
[1] I think I wasn't planning to submit it at all, but after a while Bob probably wanted to see it in action and I forgot to remove that part. (And yes, I also now make sure to use more innocuous filler text.)
I agree that submissions that bad shouldn't have a permanent record. If I see something egregious I'll ask the person in person, or via our chat software, and make a vague comment like, "Please make the changes we discussed over lunch," or whatever, in the comments of the submission.
In my experience, the problem you’re pointing out is a non-problem. I’ve never done an in person code review in my life that didn’t take place in an interview context. Yet, somehow none of my mistakes in writing code (and there have been many) have never become “a public albatross stuck around [my] neck.”
Is this a thing you’ve seen or just something you’re afraid might happen? If the former, I would say that’s an unhealthy work environment. If the latter, then why point it out?
I don't know how easy it is to avoid coming off as condescending. For example:
> "Let's say someone makes the argument that the Socratic method has major flaws related to how it is applied in practice, and that it's better to explicitly state issues with someone's approach or line of reasoning? How might you respond to such a disagreement among your cohort of senior engineers when it comes to code review practices?"
It's always going to come across as "Look I'm patiently trying to lead you arond to the conclusion that you made a mistake or don't understand things correctly, because trust me, I know better."
Also, a lot of junior people know all about how this game is played and will play along, faking the whole 'dawning realization of the error they made' thing and expressing appreciation for the master's wisdom, while secretly thinking, 'am I going to have to go through this every time I make some mistake or other?' I certainly spent quite a bit of time doing that in the past.
I think it's just a lot faster and more efficient to point out errors and issues as you see them, and any decent engineer will absorb that information pretty quickly.
If you're looking at someone's job title before making a review I'd say you're doing it wrong. Just point out things that are wrong (actual bugs) and things you think could've be done better. If there are no bugs it's probably ok to even approve it already, unless things were really poorly written. It shouldn't matter whether the person submitting the PR is a junior or the highest ranking developer in the company. Code is code.
The Socratic method is bad over asynchronous communications because if you, Socrates, made a mistake then it takes 3-5 iterations to clear that up.
1. You post a question with non-specific action intended to stimulate them to critically think and fix a defect which doesn't exist.
2. The bewildered person tries explaining what is going on blindly, not sure what you are hinting at.
3. If the general explanations connect, maybe you see your mistake and resolve otherwise you explain what you were thinking the defect was.
4. The author explains the lack of defect.
5. You apologize and resolve.
If the person has any confidence at all then they will consider this a demoralizing possibility.
Even if the person didn't make a mistake if you know there is an issue and are withholding that from them because you think them figuring it out by being stimulated from answering your question is benefitial to them, then you are not being immediately helpful in an asynchronous process that has a tendency to drag on. Our society would not be capable of the things it was today if everybody needed to reinvent the wheel frequently as a learning experience; direct communication is a strength we have.
All I am saying is, go sit down with them if you want to use the socratic method. It is multiple times more effective then.
"Socratic" method (which was used in a book, not in actual teaching, IIRC), works when the student wants to figure something out on their own but with guidance, like "You Could Have Invented X" blog posts, or tutoring math. It doesn't work when the "teacher" forces it upon an unwitting "student" to trick the student into discovering they are wrong.
I ask a lot of questions on code reviews as it's usually less easily perceived as conformational and I have come to assume that I'm missing context when something is really off. Assume that coworkers are competent but may either have or lack context. If your coworkers are genuinely incompetent, then a new position might be better than fighting though PRs.
> any senior engineer who doesn’t is committing professional malpractice
Interesting. Why not turn it around and say that any junior engineer who doesn't use comments left by his more experienced colleagues as a learning opportunity is committing professional malpractice?
Yes, and not every kid wants to be told what to do by their parents. But it still happens, because that is part of the parents' role. As it is with senior developers.
You write that as if every -ism contains contains an automatic and universal value judgement. For those of us who don't subscribe to that model, do you think you can rephrase your argument without isms?
Do you know why children don't like to be told what to do by their parents? It's not because they can't do whatever they want. It's because as a child, your agency is taken away. You have no choices but those given to you, no information but what little is given to you. You live in a world of someone else's rules and decisions, someone else's tastes, someone else's lifestyle. You are forced to live the life someone else wants, rather than your own life. And you are often given restrictions not because it's what's best for you, but it's just what's convenient for the person in power.
Children are often not given the benefit of the doubt. Things aren't explained to them, and they're lied to. Much of the time parents don't even do what's best, but instead whatever they prefer. The child may actually be fine with what a parent wants. But rather than give the child the knowledge and tools to make their own decisions and come to their own conclusions, the parent forces their child to become subservient, removing their ability to be a free human being, making their own mistakes, achieving their own goals. Children often grow up stunted by years of biased information, and the inner working of the minds of others who have grown up in the same system.
Paternalism is wrong because it's wrong to think you know what's good for others. You may know what's good for you. And you may have some experience that tells you some potential consequences of specific actions. But by pushing your own desires and limited knowledge on a child, and not permitting experimentation, growth, or making one's own mistakes, the child does not really grow. They just become a poor copy of the parent, and just as limited. Later they internalize all this and try to justify it by doing the same thing to others or their own children. But it's just a coping mechanism for the trauma they experienced as a small human with no rights.
If you actually respect your co-workers, do not treat them like children. Do not condescend. Do not limit them. And do not prevent them from making simple mistakes. Give them information, teach them, sure. But only if they want to be taught. Not because you think you have some special right to tell people what to do, or force people into situations they didn't consent to.
As a senior myself, I am happy to share information and help people learn and grow. But I would never tell a junior what to do, or lecture them, or prevent them from making mistakes. Everyone deserves to come into their experience in their own way, and be an equal member of the team.
Eh, even the socratic method is quite patronizing in many situations.
For example: underlying does a task that is correct and valid but not what the higher up envisioned or hoped for. In this case you’re just going to come off as a prick for “gently guiding me” to a conclusion I disagree with, but which I’m not allowed to (non confrontationally) articulate as you’ve corralled this conversation down one narrow path based on your personal preference
As someone who while I was a junior was starved for someone to actually teach and mentor me, I’d say this scenario played out much more often than one where I was given valuable education. yrmv
100% Agreed. Just say what you think and why. The Socratic stuff works really well if you're making up a pretend conversation where you get to write both parts, and every question gets the perfect answer, and it all gets to ends with perfect enlightenment. In the real world, your questions probably suck, and the answers probably suck more. Nothing is more obnoxious than enduring someone badly doing "the socratic method" on you.
The main problem with junior engineers is that they have narrow views of the world. Software is complex. Being experienced, is mostly about earning hard won scars through mistakes, missteps, and rewrites. It's tough to convey the scope of impact by just asking them questions. It's much more guiding to just give them what they don't yet have!
I'd much prefer: "Oh, man, so this looks like it shouldn't matter, but let me tell you how I once took down prod for 3 hours by doing this same thing. I can show you how it can fail in this really subtle way".
The post isn't about not teaching during code reviews. It's about not doing it badly, duh? I'm actually shocked at his example. It's obviously bad practice (and just jerk/toxic behavior (don't fucking be coy, EXPLICIT > implicit)). It seems like strawman or cherry picked. I never experienced in 25 years.
Quotes from article
> It’s not bad to “teach” in code reviews
after example of "proper" review
> The learning in this type of comment
Should absolutely "teach" during code reviews. Developers should always be teaching and learning from each other.
> I’m not sure if I understand the whole idea but could you explain what this method does?
Maybe...It's going to depend on the culture. If you have a passive aggressive culture, something like this is a good fit. Otherwise, to me, you're adding friction.
Yes, it might be better to make the submitter think. But if you have to be anti-truth-seek to do it, that's a net loss.
This is not a question or discussion that should go in the code review record, IMO. If you do have this question during a code review then directly go have a chat with the person who wrote the code then go back to the review. It also quicker and easier.
The worst thing during code reviews is people nit-picking my code or making comments that aren't important questions or mandatory changes. I didn't post this code review to get your two cents! I need to ship this code! Either give it a thumbs up, ask a relevant/important question with context, or ask me to change something that needs to be changed. Otherwise, shut up.
I can handle nit-picks, compliments, curiosities, etc, but post them in Slack, not in the middle of my work. I wouldn't nit-pick you during a presentation ("this use of bullet points isn't very efficient, I would do it a different way") or critique your wardrobe at the water cooler. Don't do it to my code when I'm trying to get work done.
I left my last job because of the org issues that led to it being stupidly hard to land PRs, because of one project lead always demanding significant changes because he didn't like X, do Y, when both were valid approaches, he just preferred Y.
You'd do Y, and then he'd complain about the changes that occurred because of Y, so now do Z. And so on.
I'd throw my PRs up as drafts early on, and invite his feedback as soon as possible to try to avoid this, but nope, it all came when the PR was ready for merging.
In the end I decided to work in an area that this lead didn't like and didn't know about, just to get code merged without spending two weeks in review.
I dunno, while I often DM people about minor improvements rather than comment directly on their code. There is value to public comments that the entire team can see. And as a bonus comments can go in with an approval, signalling their optionality.
I have a very different perspective. I have more than a decade of experience submitting code at Google, and I recently wrote my first PR in a new language. My reviewer knew that language well and his PR was full of nitpicks, and it was great. I learned a few things, and it helped me write cleaner code the next time around.
the first is annoyed and frustrated. It says "Dave's proposal is just an irrelevant nit pick. Who cares if I make that change or not? it won't affect the product in any meaningful way."
the second is relaxed and easygoing. It says "Dave's proposal is just an irrelevant nit pick. Who cares if I make that change or not? it won't affect the product in any meaningful way."
I listen to the second, accept the revision, and move on.
> Why care much about "style" if you already know intention clearly ?
Because it may have taken me 5 minutes to understand what the function did because its name misled me, and that was with the benefit of the context of the PR. Trying to make sense of it while debugging something broken 6 months later is going to take even longer, and getting the naming right may pay significant dividends later on.
My job is to ship software, and as an engineer/team lead it is my job to ensure the code we ship (<<< keyword) is maintainable, tested, and documented as far as any gotchas or hacks go. Ideally we want to improve the code base as well, especially when dealing with legacy code.
I think people take code reviews way too personally. Like, my priority is to ensure I don’t have headaches down the line and when I work with peers or more experience people, I barely leave any comments or get any on my PRs for them since we are all on the same wavelength and for the most part know what we are doing.
A junior engineer is a… junior engineer. They are going to have a lot of comments telling them how to write better code and a good suggestion will include a code suggestion and links to read.
It’s how they will get better, and for bigger tickets or super juniors, I sometimes pair with them to go through their ticket together.
At a certain level you just know how to identify patterns and understand how to build good software. You read books like Clean Architecture or Designing Data Intensive Applications to level up.
Juniors tend to just write yolo shit code or add more shit to a legacy shitcode repo instead of trying to improve it. They’ll add to the mess instead of writing a new clean layer on top to which we can easily maintain and modify. But that’s why you have to show them.
The only thing that helps people get better is time, being humble, and being genuinely interested themselves in becoming better at their craft. I remember my junior engineer days, and seeing my PRs filled with comments. But if I didn’t have those I don’t think I’d have leveled up so fast.