News for hackers. Stuff that matters.
Re:Absolute truths I unlearned as junior developer by dahart on Friday June 07, 2019 @10:25AM (#20124807)
Oh this is such a good comment!

> Legacy code that I wrote myself is hard to read.

Sometimes I don’t even recognize me as the author for a while. Realizing I’m reading something I wrote and can’t understand it without studying carefully has been rather surprising and reminds me of the old Kernighan quote “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?”

My goals used to be to write code that looked and felt cool to myself and others, to add features in clever ways with as little change to the function signatures and structure as possible so as to not disturb the architecture. While keeping changes small is a good goal to balance, it’s always possible to be too small and add unnamed concepts and fail to restructure around new concepts when you should. Do that a few times in a row (which I have done) and you end up with architectural spaghetti code that might look clean and modular at first glance but becomes a maintenance nightmare. My goals are now to: - make code so easy to read it’s boring, because if it looks interesting, it’s probably too clever - and to identify and name all the unnamed concepts and refactor often to accommodate new features.

Re:Absolute truths I unlearned as junior developer by enriquto on Friday June 07, 2019 @12:41PM (#20126399)
> the old Kernighan quote “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?”

This quote can be interpreted in an intelligence-positive way, to encourage you to learn by writing the cleverest possible code. Then, when you get to debug it, you will be forced to improve your skills. This interpretation is called Kernighan's lever [1] and it is very beautiful. The alternative is a life of boredom where you don't learn anything new.

[1] https://www.linusakesson.net/programming/kernighans-lever/in...

Re:Absolute truths I unlearned as junior developer by nikanj on Friday June 07, 2019 @03:39PM (#20127877)
”Prod is on fire and nobody can figure out your burrito pasta”

”Isn’t this a wonderful learning opportunity for all of us”

Debugging time is never a good time to start honing new skills.

Re:Absolute truths I unlearned as junior developer by cbsks on Friday June 07, 2019 @04:03PM (#20128070)
“Burrito pasta” is a great term! Is that something that you just came up with?

It sounds like spaghetti code but even worse because it’s covered with a messy layer of beans and guacamole and wrapped in layers of tortilla.

Re:Absolute truths I unlearned as junior developer by nikanj on Friday June 07, 2019 @05:16PM (#20128682)
Just came up with it. The complexity of monads and other post-grad level CS stuff mixed with good old spaghetti code.

Next up: some doofus who learned high-order Haskell in middle school, and takes offense of me calling it complicated.

PS: https://blog.plover.com/prog/burritos.html

Re:Absolute truths I unlearned as junior developer by enriquto on Friday June 07, 2019 @04:44PM (#20128450)
Of course, Kernighan's lever is most useful on individual projects. In an industrial context there are often other constraints. Nobody is saying that you have to always write the most clever code you can. But if you never do it, you will improve your skills very slowly, if at all.
Re:Absolute truths I unlearned as junior developer by spenczar5 on Saturday June 08, 2019 @12:13PM (#20133186)
Writing simple code is difficult, more difficult than writing clever code, and is a better skill to grow.
Re:Absolute truths I unlearned as junior developer by wtetzner on Friday June 07, 2019 @04:48PM (#20128479)
I would hope at least most of the debugging happened before the code made it to production.
Re:Absolute truths I unlearned as junior developer by munchbunny on Friday June 07, 2019 @04:30PM (#20128309)
I was just pondering this very issue. I think one of the reasons some teams end up with spaghetti code is because the developers are smart enough that they always muddle through it in the end. So when it comes to talking about technical debt, there's never a "it's too complicated," there's just "you're not trying hard enough." In that sense, it would help if the developers had a lower pain tolerance, because it would drive us to actually work hard to improve the ergonomics of our architectures.
Re:Absolute truths I unlearned as junior developer by spenczar5 on Friday June 07, 2019 @02:46PM (#20127508)
> The alternative is a life of boredom where you don't learn anything new.

Now that's an impressive logical leap.

Re:Absolute truths I unlearned as junior developer by jdlshore on Friday June 07, 2019 @12:49PM (#20126478)
False dichotomy, anyone? I learn more from trying new ideas than debugging complex code.
Re:Absolute truths I unlearned as junior developer by RugnirViking on Friday June 07, 2019 @02:30PM (#20127368)
I mean

When I try something new, usually what I learn is not that my assumptions were correct, but the more interesting part is where my assumptions were wrong. This usually only becomes apparent either when writing the code, or in some of the more interesting cases, when debugging.

Re:Absolute truths I unlearned as junior developer by joe_the_user on Saturday June 08, 2019 @12:18AM (#20130604)
This quote can be interpreted in an intelligence-positive way, to encourage you to learn by writing the cleverest possible code.

I would claim that any clever final result can be accomplished without any need for intermediate cleverness. Things that look clever to other people but are intuitive to you might be OK. Things that look clever to you should be avoided when possible.

Re:Absolute truths I unlearned as junior developer by gowld on Friday June 07, 2019 @03:17PM (#20127736)
That is absolutely horrific. I don't want to spend my energy learning the special skills needed to deal with things I should have been smart enough to prevent from ever existing.
Re:Absolute truths I unlearned as junior developer by jiveturkey on Friday June 07, 2019 @12:00PM (#20125898)
When seniors (and above) complain about the low quality of junior code, I tell them to go look at their own code from 6 months ago.

It's an endemic issue, core to the problem of poor software.

> My goals used to be to write code that looked and felt cool to myself and others, ... My goals are now to: - make code so easy to read it’s boring

Same for me, and I'm sure same to many of the folks that have advanced past senior level. The problem of other people, other senior people, needing to read, understand, and significantly modify your code is one of the reasons why you can't really advance past senior in a startup. There aren't enough experienced folks that you have to write "up to". Of course the other part of being post-senior is the ability to scale your expertise, but now I'm digressing quite far. Then once you're that advanced, you don't want to take a pay and scope cut to work at a startup. This is a major contributor to startup technical debt accumulation, one that can't readily be solved.

I still do write "cool code", for code that I will only use myself that doesn't go into production. But for all others, I write easy-to-read code. And I review code with that in mind. When comments have a typo that alter the meaning of the comment, I insist that be fixed. Juniors hate me for being too picky. (and I hate them for being too sloppy.)

Remember, the most important part of your job as senior+ is not what you do yourself, it's how you guide others.

Re:Absolute truths I unlearned as junior developer by taneq on Friday June 07, 2019 @12:35PM (#20126334)
> seniors [...] complain about the low quality of junior code [...] their own code from 6 months ago.

What classes as 'senior' that their own coding style has changed that much in 6 months? O.o

> I still do write "cool code", for code that I will only use myself that doesn't go into production. But for all others, I write easy-to-read code.

Good dev. Remember, you are not your audience. Unless you're just writing play-code in which case go nuts and be as 'clever' as you want. :D

> When comments have a typo that alter the meaning of the comment, I insist that be fixed. Juniors hate me for being too picky.

Then they're wrong, and tbh that's not something I'd accept more than once from an employee.

Re:Absolute truths I unlearned as junior developer by tomsmeding on Friday June 07, 2019 @12:53PM (#20126523)
> > seniors [...] complain about the low quality of junior code [...] their own code from 6 months ago.

> What classes as 'senior' that their own coding style has changed that much in 6 months? O.o

Your code style can remain exactly the same, and it would still happen. The reason is not that you would write the code differently today, but that you forgot the issues and edge cases that made you write it like that then, and that at the time you focused too much on the writing, not on the reading.

Re:Absolute truths I unlearned as junior developer by jdsully on Friday June 07, 2019 @03:38PM (#20127871)
Here we get to the real heart of the problem. Engineers of all levels seem to default into “this code is shit - I could do better” instead of having some empathy and considering they don’t have the whole picture.

But the wrong lesson seems to be taken away from this. It’s not that all code is shit - it’s that you aren’t good at reading the code yet if you can’t see all the little hairs and bug fixes.

Re:Absolute truths I unlearned as junior developer by mgkimsal on Friday June 07, 2019 @11:13PM (#20130401)
> Engineers of all levels seem to default into “this code is shit - I could do better” instead of having some empathy and considering they don’t have the whole picture.

several projects I've come in to - yeah, the code what shit, and yeah, I could do better. And I've done better. By asking questions, documenting the answers, writing sample data, and writing tests.

I get that code can be sloppy, have edge cases, etc. Took over a project that was halfway migrated from CI to Laravel. The migrator had close to a year on this 'migration'. We had not one unit test case, no migrations, no seeders, no integration tests when we took over. What we had was piles of half-baked uncommented model code, over-reliance on magic methods, Laravel/CI models with the same names and method names often being used in the same request but with unintentionally dissimilar behavior.

The 'code' isn't the (whole) problem. All the other stuff around the code that provides the context is the problem. We had ~ 20 tickets in a tracking system with vague notes, and were given 5 email threads of discussion about functionality questions, none with actual resolution.

> it’s that you aren’t good at reading the code yet if you can’t see all the little hairs and bug fixes.

Or... the person writing it before you simply didn't know how to write/document.

Sometimes - really, honestly - you can actually "do it better" because... really, honestly, sometimes you are actually better - more competent, more experienced, more diligent, more professional - than the person who left the code you're working on. Not always, but not never.

Re:Absolute truths I unlearned as junior developer by jdsully on Saturday June 08, 2019 @02:03AM (#20130889)
Oh absolutely code can be shit. But I’ve also seen code that’s made the company millions of dollars and run flawlessly for 20 years be called “shit” because it doesn’t look like modern code. The replacement naturally consumes many times more resources and has bugs that were long fixed in the old code.

In my experience the latter case is far more common. But I suppose experiences will differ dramatically depending on what you work on.

Re:Absolute truths I unlearned as junior developer by mgkimsal on Saturday June 08, 2019 @08:05AM (#20131939)
I'd meant to add that part as well too - code can be bad and still work, and work OK. The problems only come in when it needs to be changed.

I've advised a number of folks to care less about the code style, and focus more on making it at least understandable. I don't particularly care if you're using a factory pattern or not, but please do doc/comment someplace what the expected behavior for your 'backordering' logic is. I can fix things later if I understand what was intended, vs just what I have to guess at later.

Have worked on some projects in the last few years that are 'bad' from code perspective. One is bad, but the company as a whole operates... decently, and is improving, and more importantly, is providing a lot of value to their customers. The customers tolerate some bugs now and then because a) they still get value and b) the issues are addressed. There's a full process for changes/fixes/rollouts, and the team overall understands that there's tech debt to deal with. Some folks understand that they're still paying off tech debt from 3-4 years ago, and understand those decisions were bad, and try to avoid those same mistakes.

Hundreds of integration and unit tests (growing every week) help grow the confidence levels, and remove barriers to smaller refactoring efforts, because there's a reasonable way to detect the impact of changes. It's not perfect, but that's also understood and accepted.

Another one is the CI/Laravel situation from above. Small company, no real 'tech' people on staff - it's all 'outsourced'. They're frustrated because they see other companies progressing faster than they do, and everything seems to take 5x longer than they expect. It's because the code is bad (on many levels). If we were not trying to make any changes, and it just ran in its current state, it would still continue to make money for them, but they want new features, which requires actually understanding how everything fits together. It took two people several months to have a reasonable understanding of how all the running parts fit together (while also trying to add new features/etc), and finally get a small number of unit tests in place.

Re:Absolute truths I unlearned as junior developer by taneq on Friday June 07, 2019 @01:18PM (#20126751)
...you don't remember what you were doing 6 months ago? I'm sorry, that's still not a good excuse. Maybe you don't remember every tiny facet but hopefully you'd have a general idea. And above all that, if you're a senior dev then you'd understand that "this code is unfamiliar" does NOT mean "this code is bad."

I mean really, "this code is unfamiliar therefore it's messy therefore we should rewrite it" is a flaming red flag. Chesterton's fence, people!

Re:Absolute truths I unlearned as junior developer by pjscott on Friday June 07, 2019 @04:23PM (#20128252)
One of my favorite things about comments in programming is that you can stick a label on that fence explaining why it's there. One of my biggest frustrations is that so many people don't bother, even when it would literally be just one little sentence.
Re:Absolute truths I unlearned as junior developer by thaumasiotes on Saturday June 08, 2019 @01:25AM (#20130789)
> One of my favorite things about comments in programming is that you can stick a label on that fence explaining why it's there.

This is routine for ordinary cultural practices as well. However, the common explanation for a given cultural practice usually has nothing to do with the actual reasons it might be a good idea.

Re:Absolute truths I unlearned as junior developer by beat on Friday June 07, 2019 @05:21PM (#20128729)
Unknown unknowns.

My coding style hasn't really changed in years - frankly, I don't write a lot of code, I do other things. But I often run into situations where I'm irritated at my own bad code from months earlier, when the shortcomings of the code are actually driven by things I know now that I didn't know then.

Re:Absolute truths I unlearned as junior developer by alexanderdmitri on Friday June 07, 2019 @04:36PM (#20128368)
Review process surely mitigates differences between "junior" and "senior" code?
Re:Absolute truths I unlearned as junior developer by AdamM12 on Friday June 07, 2019 @09:08PM (#20129945)
This also would require that devs who are on the PR reviews ACTUALLY look at the code. In about every job I've worked at in my short career there are people I work with that I don't trust them to actually review my code. I've come to accept that. I instead make sure the people I know will do a decent job are on the PR. Some people will just look at the diff and an even smaller few will actually pull the branch locally so they can see the entire context. That being said I always do my best to review other peoples code regardless of whether or not they will review mine.
Re:Absolute truths I unlearned as junior developer by Aeolun on Friday June 07, 2019 @05:00PM (#20128576)
Not really. It just ensures no really atrocious code makes it into master.

Of course you can stall any junior merge request until it looks like senior code, but at that point you might as well write it yourself.

Re:Absolute truths I unlearned as junior developer by alexanderdmitri on Friday June 07, 2019 @06:37PM (#20129263)
I don't know if it's stalling so much as taking the time to request changes / pair up and teach.

If bad code is getting merged, that's tech debt / time someone else is going to have to spend anyway, plus the time needed to identify the issue and triage down the line. I would think it's better investment to use that time up front and help the jumior level up too.

Re:Absolute truths I unlearned as junior developer by RussianCow on Friday June 07, 2019 @11:10AM (#20125311)
> Sometimes I don’t even recognize me as the author for a while.

This happened to me just yesterday! I was helping a co-worker with a problem, and I noticed some redundant code in the same function, so I told him he could simplify it while he was there. His response was, "...but you wrote that". (And as it turns out, only a few days prior!)

Re:Absolute truths I unlearned as junior developer by gmueckl on Friday June 07, 2019 @01:14PM (#20126720)
This is why I will point out issues in code only on the form of stating potential improvements as best as I can. I especially try to avoid hating on the author - it might have been me or the boss who's standing nearby...

In fact, I often conciously refrain from using blame on an "interesting" piece of code because it doesn't matter who wrote it. Looking it up would just satisfy idle curiosity, but yield noninsight into how to improve the code. In fact, I think that blame should just list the commits, but hide the authors by default. "What changed? " and "how?" are always much more pressing questions than "who?".

Re:Absolute truths I unlearned as junior developer by Macha on Friday June 07, 2019 @01:57PM (#20127113)
My experience varies a lot. Maybe it's just my colleagues write better commit messages but blame (and looking up the PR and code review) is often a good method of understanding why the code is that way
Re:Absolute truths I unlearned as junior developer by gmueckl on Friday June 07, 2019 @06:24PM (#20129185)
Yes, but blame puts the focus too much on the authors instead of the changes themselves. I also use it to understand how code evolved over time, but only in circumstances where I suspect the history to hold import clues.

Pinning bad work on a person does not make progress. Fixing bad code does.

Re:Absolute truths I unlearned as junior developer by retiredcoder on Friday June 07, 2019 @02:53PM (#20127565)
I am coming back from vacations next week and have 2 PRs to finish (couldn’t merge before because they are high risk), I am antecipating a lot of pain just to pick them up where I left off... I would rather do my tax returns instead lol
Re:Absolute truths I unlearned as junior developer by tigershark on Friday June 07, 2019 @06:19PM (#20129144)
It always happens to me while I approve my own pull requests to master.. :’(