News for hackers. Stuff that matters.
Re:Absolute truths I unlearned as junior developer by Tade0 on Friday June 07, 2019 @02:19PM (#20127278)
Here's what happened to me(A) and a friend(B) from a former workplace of mine(open-source project):

B: Take a look at this shit code that I found.

A: Whoah, it really is shit. Blame it so that we can see what kind of genious is behind this.

B: ...

A: Well?

B: Apparently you wrote and I reviewed/approved it.

Re:Absolute truths I unlearned as junior developer by kbp on Friday June 07, 2019 @05:00PM (#20128574)
The "who wrote this?" mentality is a trap that's good to avoid. Get comfortable with different ways of writing something that, while they might have different tradeoffs, accomplish the same thing, and try to see past that. Understand that most code wasn't written by anybody--lines 1 and 3 were written by Alice a year ago, line 2 was written by Bob 2 years ago, and line 4 was written by Alice yesterday. `git blame` is very useful for seeing the change in context, which can give a lot of insight into why it's written that way, but usually the author isn't very useful to know, unless you're planning to ask them about it. Sometimes it's useful if you happen to know that the author isn't very familiar with something when you're wondering why they didn't use it, but try to keep in mind what the actual benefits of your way are, whether they're especially pressing, and that the other person might have written it differently because they were thinking about other concerns that you forgot.
Re:Absolute truths I unlearned as junior developer by milesvp on Friday June 07, 2019 @10:33PM (#20130273)
I agree that “who wrote this” is dangerous, and git blame is a terribad name. I will say though, if you can avoid value judgements, then knowing who wrote a block of code is super valuable in a legacy code base. I’ve found that every dev I’ve ever worked with has very real strengths and weaknesses. And knowing who wrote a piece of code can drastically reduce the time it takes me to find hard bugs. It often goes something like, so and so tends to forget certain kinds of edge cases, but they never seem to screw up this kind of logic... so I bet the problem is related to... ah found the problem. But never blame someone for creating bugs, unless it’s really egregious, and then, only if you can help them with better habits going forwards.
Re:Absolute truths I unlearned as junior developer by collinmanderson on Monday June 10, 2019 @04:59PM (#20150789)
Yes, "blame" is not a good word.

Use "git annotate" instead.

Re:Absolute truths I unlearned as junior developer by C4stor on Saturday June 08, 2019 @04:06AM (#20131236)
I really like this approach of using git blame, it's original thinking and highlights how much human components there are in developing.
Re:Absolute truths I unlearned as junior developer by sirmarksalot on Friday June 07, 2019 @06:27PM (#20129204)
While lots of legacy code emerges organically the way you describe, there are in fact many people in the industry who I'd call "legacy coders." People who saw Dijkstra's "Goto considered harmful" and scoffed, "all these 'for' loops are much less readable than my 'goto loop1' solution." People who use global variables because parameter-based implementations are "needlessly complex."

Basically, not everyone works for Google.

Re:Absolute truths I unlearned as junior developer by sk0g on Saturday June 08, 2019 @01:10PM (#20133569)
You say that, but Golang has gotos, while being a very minimal language. Not everyone at Google is an amazing developer that's fully up to date with best practices and patterns.

Not that that needs to be said, no matter the company (if it's of any decent size.)

Re:Absolute truths I unlearned as junior developer by saagarjha on Friday June 07, 2019 @06:33PM (#20129240)
It’s often helpful to know who wrote a line of code, because then I can put myself into their shoes and try to figure out what was going on their mind when they wrote it.
Re:Absolute truths I unlearned as junior developer by AmericanChopper on Friday June 07, 2019 @05:33PM (#20128823)
I’ve always found the svn alias ‘svn praise’ pretty entertaining for this reason.
Re:Absolute truths I unlearned as junior developer by collinmanderson on Monday June 10, 2019 @05:00PM (#20150801)
git has "git annotate"
Re:Absolute truths I unlearned as junior developer by Rapzid on Friday June 07, 2019 @07:23PM (#20129504)
Assuming those lines were getting out of hand, I think it would be a valid question as to why they were not tidied up during the review of the line 4 addition by Alice.
Re:Absolute truths I unlearned as junior developer by tonyedgecombe on Saturday June 08, 2019 @04:32AM (#20131316)
It’s Friday afternoon, you are exhausted after a busy week, the business is pushing for a fix before you leave and you have committed to be home by 6pm so your spouse can go out.
Re:Absolute truths I unlearned as junior developer by war1025 on Saturday June 08, 2019 @12:28AM (#20130641)
`git log -p` is vastly superior to `git blame` for determining why a file is the way it is.
Re:Absolute truths I unlearned as junior developer by eru on Saturday June 08, 2019 @11:24AM (#20132861)
That gives you all the history (or all the history of a file).

Git blame quickly gives you the commits you are likely interested in, then you can use them as a starting point for your git log digging.

Re:Absolute truths I unlearned as junior developer by koala_man on Friday June 07, 2019 @04:36PM (#20128359)
I've had that happen several times, but once I actually did the inverse.

I was working on an extraordinarily bad codebase, and stumbled upon some modular, reusable code that made my life way easier. I wondered who wrote this rare gem in that pile of shit, and checked `svn praise` for a change.

It was me.

It would have been the highlight of my then short career, if not for the fact that it meant there were no other semi-competent people on that project.

Re:Absolute truths I unlearned as junior developer by harrisreynolds on Friday June 07, 2019 @03:18PM (#20127747)
This is really funny. So good. I ask all the time, "Who wrote this shit??" knowing it was probably me.
Re:Absolute truths I unlearned as junior developer by heelix on Friday June 07, 2019 @08:17PM (#20129729)
Honestly, this is usually a good sign. I'll code at the edge of my current skill. Six months from now, I hope I can look at that code and consider it primitive from where I hope to be then.
Re:Absolute truths I unlearned as junior developer by yxhuvud on Friday June 07, 2019 @04:29PM (#20128301)
That is the only time I dare ask it. When else do I dare? Someone might take it the wrong way otherwise.
Re:Absolute truths I unlearned as junior developer by carapace on Monday June 10, 2019 @02:52AM (#20144455)
*genius