r/AskProgramming • • Nov 24 '22

Senior Devs: What do you find yourself explaining to junior / other devs over and over?

I was thinking about this the other day and realized that there are a handful of things that I end up 'teaching' other devs about. I was wondering what types of things you all tend to explain over and over?

Here are my top 3:

  1. SSL - I've had to explain how the handshake / verification process works so many times that I literally have a note saved with an explanation I can copy/paste. They apparently don't teach this to new programmers?

  2. Why writing your own encryption method is a really bad idea. Just don't.

  3. Sometimes rewriting IS better than refactoring.

I'm curious to hear what the rest of you are seeing/hearing. Maybe this can turn into a decent knowledge share.

76 Upvotes

62 comments sorted by

57

u/plexxonic Nov 24 '22

That I don't know everything. I have literally forgotten more than I know.

Fucking hell, 90% of my job is research, reading and fucking around with an idea then working with others to implement it.

If any junior dev is reading this, senior devs google just as much as you do. We (though trial and a metricfuckton of errors) have learned to take one result and fine tune it for further results.

Take the time to research a problem. If you have to learn some new tech along the way, do so.

18

u/terrortone Nov 24 '22

Bravo. Yes, this times 100. I'll only add that senior devs tend to know things off the tops of their heads (sometimes) only BECAUSE we've googled it a thousand times and our brains finally decided to keep that information.

I'll be honest, I've been at this over a decade and I still google the simplest programming 101 level stuff. My brain refuses to remember a lot of syntax.

5

u/[deleted] Nov 24 '22

Either that or because we googled it there and then, but are able to identify the correct result and then find the relevant bit quickly. I swear some of our junior engineers think the rest of us have all memorised entire RFCs.

3

u/hadidotj Nov 24 '22

I feel this 100%. I have been feeling like a rookie again doing a side project in Java. 5 years ago at my last job I was a Java engineer, now C#. Java feels so different now! Streams are completely new, and I am googling constantly. New error, google, new error, google, error from before, google...

1

u/jinzo7playa Dec 22 '22

this is really helpful stuff, as im going to be graduated next year its good to know and what to expect lol xD

3

u/---cameron Nov 24 '22 edited Nov 24 '22

There's this fantasy where the experts must know every detail down to the atoms of everything. That's equivalent to loading the entire world into RAM, and as a programmer who teaches a computer to use information, you too learn this is not the way to, eh, use information. You keep things in memory that you're actually dealing with in your problem space, and you also sort of keep little reminders in memory that make it a lot easier to find the information you might need later, but you don't hold on to it all yourself. We have in fact offloaded that feature to the computer itself, to things like google, so that we too are literally using the power of the computer, merging with the computer of sorts, to properly do our job of working on the computer, having it fetch the information when we need it.

Then there's just the skill of intuitively understanding how things work so that even if the idea is completely new, reading about it is equivalent to "a flabberdrow is a blue bird wearing a hat". I may not have known what a flabberdrow is, but I understand blue, birds, and hats, so now I'm good.

3

u/wrosecrans Nov 24 '22

One thing I point out sometimes is that for a real rough round number, a novel is about a megabyte of plain text. So in the days of machines with about a megabyte of RAM, a person could theoretically sit down and read all the code running on a machine.

A person can't just sit down and read thousands of novels, and catch every single plot hole or character quirk, or sly reference, etc. It's just physically impossible. A modern machine with 16 GB of RAM isn't limited to 16 GB of code, thanks to stuff like paging and dynamic linking, a current process could read in additional code at any moment. And even if you could read all of it in great detail, it would take so long that you will definitely get a software update while you are reading, so your magic-level expertise is already out of date.

2

u/wearecyborg Nov 24 '22

The RAM analogy is a pretty accurate one. I will sometimes completely forget what my ticket was even about let alone what I did once I set it to done (obviously I can recall it quickly by reading about it). Need to free up that working memory.

3

u/[deleted] Nov 24 '22

Not just junior devs, anyone close to a project. One of my most used phrases in answer to an abundance of questions is "No, I have not memorised [our entire codebase|the whole JDK|All of AWS]".

2

u/shockjavazon Nov 24 '22

Thank you for this.

2

u/NutGoblin2 Nov 25 '22

“I cannot remember the books I’ve read any more than the meals I have eaten; even so, they have made me.”

2

u/Polatrite Nov 25 '22

I checked my browser history after a 7 hour programming day the other day and only had one google search.

It felt like a milestone!

(I've been programming for over 20 years.)

10

u/otakumw Nov 24 '22

Can you paste the note, sounds useful for the same reason you have.

31

u/terrortone Nov 24 '22 edited Nov 24 '22

"Hi <colleague>,

SSL is fairly straightforward from a high level. Your computer (browser, program, etc) sends a message to the server to initiate the exchange, the server sends back a certificate, your computer verifies the authenticity of this certificate with a Certificate Authority (self-signed certs are typically rejected unless specifically allowed), your computer sends back a signing key, the server decrypts this key and uses it to encrypt content, and (finally) your computer decrypts the content using this agreed upon key.

Some common errors/issues you may see:

1.The 'ERR_SSL_VERSION_OR_CIPHER_MISMATCH' error typically either means the server and client are not configured with the same cypher suite or the same minimum TLS version.

2. A 'CERTIFICATE_VERIFY_FAILED' error means there was a problem in the cert verification process, most likely caused by a self-signed cert or a cert from an otherwise untrusted source.Your browser/computer must either trust the certificate from the server or be configured to skip verification (which is a bad idea for production code).

3. Modern web servers will not allow you to downgrade SSL to HTTP, you will likely see a 'protocol mismatch' error or similar if this happens."

I tend to copy/paste different bits of that, depending on the situation.

5

u/otakumw Nov 24 '22

Thanks for giving that up!

4

u/terrortone Nov 24 '22

No problem!

11

u/---cameron Nov 24 '22 edited Nov 24 '22

They apparently don't teach this to new programmers?

To be fair, I basically never have to deal with SSL these days and wouldn't have been able to tell you any of the details, nor remember its exact purpose despite being something basic (well, I'd probably half remember but wouldn't be sure if I was correct). Big thing that sets apart long time programmers though is I wouldn't have to ask, it would take me 5 seconds to read through the details of SSL and remember what's going on, and then a little bit longer for any specific details I need if I need them (such as the meaning of the ERR_SSL_VERSION_OR_CIPHER_MISMATCH error).

Other issue with a newer programmer is they might start working on something where they don't even know they need to be aware of SSL, but that's another thing you sort of adapt to over time (figuring out what sort of things you're gonna need to be aware of, what sort of things to download into your memory to work in your current problem space)

4

u/[deleted] Nov 24 '22

I think it's important to clarify that their networking stack is doing most of this under the covers, all you need to do is configure it. I say that because only this week I've had someone ask me to fix a bug by adding second client hello.

1

u/Qweesdy Nov 24 '22

Nice, but I'm going to need a little more detail. What kind of cipher will I need to implement to avoid the "cipher mismatch" error? :-)

1

u/jammasterpaz Nov 24 '22

You legend. cheers.

1

u/IAmInBed123 Nov 25 '22

It would be awesome if someone could getter all the questions and the answers/explanations, like a course almost! As a junior I'd love that! At my job the seniors aren't really taking time to explain/get a bit mad if I ask. So maybe reddit seniors could be my guide!

5

u/[deleted] Nov 24 '22

That SSL has been deprecated for over a decade! (sorry)

That readability is far and away the most important thing in their code.

That learning the ins and outs of a given framework will make their lives a lot easier. So often I see them coding something by hand that a few lines of config would do, and then I have to watch them try and persuade the framework to use their code.

That error messages and stack traces are not there for the fun of it.

That software is not just the source code. You haven't delivered that work until there's infrastructure for it to exist in as well. Pertinent here because we are 100 IaC, but of course other companies, YMMV. But I still think, almost without exception, that simply delivering source code isn't enough.

That part of our job is to say no. You do not need to keep the product owner happy, you need to make sure he's being realistic. It's ok to stand up against them.

2

u/terrortone Nov 25 '22

Touche! I'm guilty of using SSL and TLS interchangeably. I appreciate you calling that out.

4

u/caboosetp Nov 24 '22

That readability is far and away the most important thing in their code

I try to ingrain this in my students. They always seem to get in this competition to write the most compact code, and it just makes everything more difficult from understanding what it does to debugging problems.

You should only really chain simple functions that you're certain won't error out or you'll ever need to break on. Otherwise just store it in steps in variables. You'll thank yourself later when you're stepping through the code with a debugger.

2

u/hi65435 Nov 24 '22

Yeah some sort of holistic thinking is key, Features start with the requirement and end when the customer can use them. So much effort can be saved all along the way

19

u/CartmansEvilTwin Nov 24 '22

Dependency Injection/CDI in Java. Each time it melts their brains for some reason.

On a similar note: accepting Voodoo, but not too much. There's a fine balance between accepting that a black box exists and works, and just recklessly throwing stuff together until it roughly looks like it does what I'm asking for.

Oh, and Kubernetes. Not only juniors, but POs, older devs from other areas, PMs, customers... Of course in different depths and with different aspects highlighted.

21

u/wrosecrans Nov 24 '22

Some stuff that has come up over time that leaps back from memory...

We can't fix NUMA in software.

GPU's are very parallel, but that usually means working on a million pixels for one image at a time, and not working on 1 million images at once.

GPU's are very parallel, but multithreaded OpenGL is a massive pain in the ass.

GPU's are very parallel, but Vulkan queues and some other pain points still make serial code inevitable sometimes.

GPU's are very parallel, but if you just spin on the CPU waiting for the GPU to finish what you submitted, you are still only doing one thing at a time. (And it might have been faster to just do it on the CPU rather than pay the overhead of copies and waits.)

GPU's are very parallel, but Amdahl's law didn't vanish just because nVidia make nice looking powerpoint slides.

Dumb algorithms are often fine. Beyond that, dumb algorithms are often optimal.

Locality matters more than cleverness.

Despite what Big-O tells you, memory accesses are not remotely constant cost.

We call the little machines "computers" but only a small amount of the mass/transistor/power budget is actually going to computations. In the engineering of large systems, this pattern holds true. Often times the majority of engineering goes into moving data, storing data, formatting data, etc., and adding two numbers or whatever is effectively free.

You need to know the cost of something before you opine on the benefit of optimizing it away.

That class you took about how to implement that thing was mainly about making sure you understood the thing well enough to use it, not making sure you understood it well enough to implement it repeatedly. First off, you'll probably never actually need to implement it. Second off, if you ever do need to make a real world implementation, you haven't understood a fraction of the fiddly garbage you have to have around to make something robust and efficient.

Build system work is real work. Getting from source code to end user is a lot of steps and those steps matter.

Complexity kills.

Things last forever, when you least expect. If you try to name anything "new," "modern," "next-gen," it will spend the majority of its existence with that name being stupid and ironic, and forcing people to make dumb clarifying statements about "the old new project NG, not the current new project NG." Such names should be an immediate firing offense.

I don't fucking know, and I can't google it and send you what I find any faster than you can google it yourself.

Always understand your audience when making an argument. You need to understand what would convince them, not just repeat what convinced you. A long running issue I had at previous job was a coworker who kept insisting we could replace some off the shelf tool he didn't like with an in-house thing. We had many conversations where he kept trying to explain why it was possible for us to write our own. I kept explaining to him that I had written the previous implementation we used before we switched to the off the shelf thing. I bloody well knew it was possible, I had done it. He kept arguing how easy it would be, how he had relevant expertise, etc. The bastard never listened to me when I told him I understood that it was possible to make one in house, and that wasn't the issue. He wasted so much of both of our time because he kept trying to convince me of something by repeating what had convinced him that I am still annoyed. If you ever talk to a senior VP, for example, it's very unlikely that they care about the clever technical details you are proud of. If you get a no, understand why that person is a no and why their opinion is different from yours. If your argument is "red is my favorite color," repeating that it'll be red isn't gonna convince somebody who just prefers yellow. No matter how many times you go back and clarify "but this will be red."

Admitting there are some laws of physics issues with locality and things like NUMA isn't necessarily "prematurely optimizing for specific hardware." Pretending locality is not an issue because your code assumes flat memory hierarchies is prematurely optimizing for specific hardware that you don't use.

3

u/Phone-Metal Nov 25 '22

The only thing I'll remember from this in a long term is that GPU's are very parallel

10

u/KiwiOk6697 Nov 24 '22
  • The importance of readable code. Write the code in same style as rest of the project and don't overengineer it.

  • Code contains most of the answers to your questions, read from there.

The bigger the project is, the more important those points are.

15

u/qlkzy Nov 24 '22
  1. Idempotency

  2. Database transactions (and why they usually don't span processes/services)

  3. Logs are an API

  4. That library code is no more capable of breaking the laws of physics than application code is

I can confirm they don't teach people TLS, and a few years ago that would have definitely made my list, but I changed jobs and it comes up less now (everyone just trusts Kubernetes to be magic...)

14

u/RonSijm Nov 24 '22

1: Don't write comments what a function is doing. I can see what it's doing. Write comments why it's doing it

2: Stop Method().Chainging(Everything()).And().Innerlinking(EveryMethod()); - if one of those random things throws an exception, I have no idea what happened, and I can't easily put breakpoints in the function to see what happened. Just put everything in variables first - the compiler will optimize everything together anyways

3: Quadruple espresso extra strong until the entire cup is full. No normal coffee is not the same

‎

/s #3 is a joke, I don't make juniors get me my coffee

2

u/miyakohouou Nov 24 '22

The intuition to do method chaining is a good one- it very clearly conveys the idea that you have a sequence of transformations on some data, and allows the reader to focus on the flow of data and gives you a chance to abstract away the details of error handling. The main issue is just that you need to make sure you're implementing it correctly. They should all be pure functions, and should handle errors by returning an error value, rather than raising an exception. Done correctly, this can be a great way to write compact and clear code, and it can be safer than manually dealing with error handling because the code is already instrumented to make error handling automatic.

1

u/Bratmon Nov 25 '22

If your code returns an error value, you can't do method chaining anyway (unless you're chaining the errors).

1

u/miyakohouou Nov 25 '22

Chaining together errors is close. The idea is that you return values that can represent some valid return value or an error. Then you chain those together.

As a really simplified example, imagine that you have a class like this (in pseudo-code):

class SuccessOrFailure <T>
  Error currentError
  T currentValue
  SuccessOrFailure(T val, Error err):
    currentValue = val
    currentError = err
  
  /* implementation details vary between languages */
  SuccessOrFailure<T2> callMethod(Method f, args...):
     if (NULL != self.currentError):
       return self
     return self.currentValue.callMethod(f, args)
  
SuccessOrFailure<T> success(T val):
  return SuccessOrError(val, NULL)

SuccessOrFailure<T> failure(Error err):
  return SuccessOrError(NULL, err)

The behavior of a class like this is that it can hold some value, or an error. Any time we call any method on SuccessOrFailure it first checks to see if it's an error value. If it is, it doesn't do anything, because the method chain has failed. If it's not in a failure state, then it just passes through the method to it's value. As long as each method returns a SuccessOrFailure value, then we can keep chaining things together. If we want to work with functions that don't already return SuccessOrFailure values, then we can write functions to transform them.

This approach is essentially the same as what some languages call flatMap. You'll sometimes see it used with Option types, but we can do it with more robust error types too. At first it seems like it might be a little bit convoluted, but the long term benefits can bit a big payoff if you're using a language that doesn't make it too awkward. That's the biggest drawback- this tends to work best in either dynamically typed languages, or languages with more expressive type systems. It can get a bit wonky trying to do it in some languages because the type system won't really let you express some of the constraints very well.

7

u/Ran4 Nov 24 '22

The biggest thing is probably, "don't just ignore errors".

I see so, so, so much code written like

def do_something():
    try:
        # ...some complicated multi-line setup
        result = some_function()
    except Exception:
        return None
    return result

The exception is eaten, and the caller thinks they got a result but the operation might have failed. And you can't even detect this until the operation fails, so it's easy for code like this to reach production. And it happens in nearly all languages due to null (the worst programming mistake ever, literally worse than goto).


And working with machine learning/data engineer people, people trying to get the head of an array that might be empty. My first approach when they ask me to go through a 1000+ line codebase to make it "production ready" is to grep all files for [0] and ask at every spot, "will it ever happen that this list/array/whatever is empty?".

1

u/beaverforest Nov 25 '22

Hey Ran4, I am only in school so please forgive me for asking, but what would the optimal way to resolve a try/except clause. You would want to create a custom error class that says "array has no elements" and return that? Thank you and have mercy on us all.

2

u/Poddster Nov 25 '22

Just throw the error up the stack until a properly qualified piece of code can make the real decisions about trying again or giving up etc

4

u/[deleted] Nov 25 '22
  1. don’t ship on Friday if you value your weekend. If you fuck up something you’re going to be the one people expect to stick around and fix it

  2. don’t work yourself to death, if you’re Sick take days off, don’t do overtime without being paid, there’s usually nothing we work on that will cause someone to die if it’s not done on time

  3. if you’re stuck on a problem take a break, itl still be broken tomorrow but at least you’re looking at it fresh.

  4. if you get asked to do stuff by a certain time or date the answers are yes or no, if you’re not sure but say you’ll try people hear yes. It’s better to say you can’t do it and why and then discuss what stops you.

3

u/[deleted] Nov 24 '22 edited Jan 02 '26

quicksand mighty plants pot tender deliver bike toy live cover

This post was mass deleted and anonymized with Redact

1

u/caboosetp Nov 24 '22

Never go for more than a day or two without checking in or asking a question to at least one co-worker.

This with bugs. Yeah, sometimes bugs really are that complicated, but more often than not if it takes more than 2 days alone, someone on the team probably has insight you don't to solve it a lot faster. Otherwise, if it really is that complicated, it's probably helpful to have multiple people on it anyways.

3

u/amasterblaster Nov 25 '22

1- literally type your f***ing question into google and try the top result

2 - No, don't then do a 2 hour research paper on each question

3 - No, don't fiddle for 2 hours on a bug -- message me for help then

I understand this three step process is difficult. I try to explain this OVER AND OVER, and people always say "I can't tell when I should research, and when I should ask for help".

I think the largest issue junior devs face is just a complete lack of "common dev sense".

2

u/KarmaWhoreRepeating Nov 24 '22

That, even though C++17 handles nicely the division by zero, you shouldn't rely solely on the caught exception, but rather test your edge case.

2

u/zyzany Nov 24 '22

To keep it simple.

2

u/[deleted] Nov 25 '22

That we're not here to create art, we're here to solve problems. Sometimes we write code to solve those problems, usually even, but "pretty" code that doesn't solve the problem as well as "ugly" code isn't better.

1

u/[deleted] Nov 25 '22

How to debug properly; how to start measuring at one end until something breaks. I see a lot get thrown at the wall to see what sticks. I started in frontline support and basically debugged stuff as a job, but it’s clear CS students are never taught how to start at one some point you know is working and move towards where something is failing.

1

u/_101010_ Nov 25 '22

That latency is not the only thing that matters. Every damn trade-off. We work on a service with no users that could 100x in e2e latency and it wouldn't matter.

Example: This team split a single db table into ~10 tables for speed. Each table has like 5-10 rows, and it's complicated as hell to query the tables because you always need information from 3+ tables to do anything.

I could go on about this. It's mindblowingly frustrating

1

u/Xaneris47 Nov 25 '22

I am constantly reminding and explaining to people what issues they can and cannot message me about. My coworkers, especially the new ones, write to messengers right away.

There are two major problems here. First, they don't express a thought well in this way and often write "chunks of thoughts" that require clarifying questions, or they themselves begin writing a few clarifying remarks. It's much better to write a linked text all at once, however, messengers encourage writing text in pieces.

The second problem is that if a question needs some time to respond, I may be unable to go through with it myself and end up forgetting about it later. When you have 1-2 people writing to you, this is not a problem. However, when you are coordinating the work of a big number of people, the constant flow of messages becomes tough to manage, and you may forget to respond to something, etc.

That's why I avoid sending messages that need more than one pair of "yes/no". Anything else should be written as a complete thought in an email. Or you can arrange to call and talk virtually if you are working remotely. But please don't send endless messages on Messenger.

1

u/[deleted] Nov 25 '22

That h is not a proper variable name in like 99% of the cases. Sadly not only to juniors, and i'm not even fully senior yet

1

u/g4m3c0d3r Nov 24 '22

I had to take this question out of my interview questions pool because of how few got it: how do you tell if the high bit in a byte is set or not. It’s not a trick question, it’s just that they don’t emphasize basic computer architecture in college anymore. This was for game programming in C++.

-1

u/drjeats Nov 24 '22

That's surprising to me, I feel like even real basic systems or C classes I took touch on this a little bit, and I'd have expected juniors going for game roles to have self selected for knowing a little about bitwise ops and twos complement.

I guess it's not a big deal because it's not that deep of a topic to have explained, and they'll pick it up anyway trying to work with bitflag fields.

1

u/hadidotj Nov 24 '22

Oh man, #3 just hit hard. As a manager, I literally rewrote a whole price calculation method this week because my 3 attempts to get a junior developer to fix it failed. They kept adding in more convoluted code with zero comments.

My solution was half the code, and commented each block with a simple explanation and example (i.e. get the requested UoM relative to base UoM. Ex: 1 Box = 10 Each).

Boy, the look on those two devs faces when I showed it to them! Definitely think it was a learning moment. They probably were afraid to break it worse than it was, but that's why you test (and have a QA + UAT phase)!

0

u/BobbyThrowaway6969 Nov 24 '22

I find myself explaining to juniors how/why they should avoid allocations & copies everywhere. Preallocate your stuff.

2

u/Cybyss Nov 25 '22

I take it you're referring to junior C/C++ programmers?

You can blame this on universities primarily using Java in most of their courses.

I've been a C# developer for several years, but really wouldn't have any clue what the best practices are regarding memory management were I to suddenly get a C++ gig.

1

u/BobbyThrowaway6969 Nov 25 '22

Ah true. C++ is powerful but needs a lot of care.

0

u/Horatio_ATM Nov 24 '22

That the only code buggier than old code is new code, so pushing for rewrites is not a quality panacea.

-1

u/wsppan Nov 24 '22

Restarting the service/app/VM does not solve the problem. It's not a solution and it prevents you from debugging the issue.

Always check your return types for errors.

Always provide ways for things to fail and log where and why.

Don't allocate memory without freeing it. Don't write code that expects others to free memory you allocate.

Edge cases will happen. Prepare for them.

Document what a function does and why it exists. Not how it works.

0

u/scorr204 Nov 25 '22

God I HATE when people ask a question only so they can answer it....

-1

u/feedjaypie Nov 25 '22

Every. Damn. Thing.

-1

u/reboog711 Nov 25 '22
  1. SSL is not really a programming thing, so I'm not sure why this would be covered in a programming curriculum; but I am surprised it needs explaining.

  2. Writing your own encryption algorithm could be a fantastic learning experience. But, I convincing people it is better to use something that exists than writing it on your own from scratch is sometimes an uphill battle.

  3. Not sure I agree. This is a "it depends" thing. It is going to be a hard sell to convince me that it is better to re-write something than refactor it.

2

u/terrortone Nov 25 '22

SSL being a programming thing depends on project scope. For instance, I've worked on IoT projects where the stack was built from the ground up. Knowing how SSL/TLS worked at a low level was critical.

I stand by my claim that encryption should NEVER be written from scratch. Hobby/educational projects are a different story, for sure. In production, you should never invent your own algorithm. Cryptographic standards go through very rigorous testing by a large, committed community to ensure they are sound. Rolling your own encryption is a great way to get hacked.

My last point is for sure dependent on a lot of factors, I agree with you there. I try to urge other developers to weigh refactoring against rewriting as an option, mostly to prevent a vicious refactoring cycle that never ends.

0

u/[deleted] Nov 24 '22

[deleted]

1

u/caboosetp Nov 24 '22

This is a fun thing to try to teach though because the opposite can also happen. People asking for help too fast isn't good, but people waiting too long is also bad. Knowing what a good effort is takes experience. I generally tell my team 2 hours without progress is a good time to ask for help. A day or two with slow progress but no solution is a good time to ask if anyone has a better way or other resources.