Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Paolomania
Apr 26, 2006

New Yorp New Yorp posted:

Code coverage does not guarantee that code is bug-free or well-tested, just that someone has attempted to test it. Code coverage requirements are just asking to be gamed.

Coverage may not be perfect but it is leagues better then no coverage. A test that exists, even if it is wrong, is a starting point for a fix when a bug is found. Coverage also tells you which error cases you are not exercising.

Adbot
ADBOT LOVES YOU

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

TooMuchAbstraction posted:

How do y'all get your junior teammates to build better software? At the moment all of my code reviews are involving a lot of back-and-forth because they're sending poo poo out for review really before it's ready. I remain hopeful that they're capable of better (i.e. they're not just crappy devs) but I don't know how to go about improving their output.

On a related note, how do you get your teammates to do more rigorous code reviews? Because those not-really-ready change lists are getting a pass from other teammates despite glaring flaws.

I am assuming you're talking about folks who are clearly engaged with the work and otherwise enthusiastic - but just can't seem to give a drat about quality?
I've got a pet theory that this is especially common in software mostly because of the esoteric prestige that comes with BEING A COMPUTER PROGRAMMER! You get folks who love being a programmer more than they really love programming. Who get seduced by the feeling of 'oh gently caress yes everyone thinks I'm a supergenius when I tell them I WRITE SOFTWARE' rather than loving the work itself enough to give a poo poo about the bigger picture.

(Note, this isn't necessarily limited to programming and tech, but I think it's more prevalent here)

Your only shot is to try and earn enough respect in their eyes to be able to have a friendly and serious career advice talk with them over lunch. A sort of 'here's a bit of advice I wish someone had given me early on in my career' type talk. Either they'll listen or they'll figure they're smarter than you and ignore it. At least then you'll know and can refocus your energy and efforts and attention where it's better used.

redleader
Aug 18, 2005

Engage according to operational parameters

TooMuchAbstraction posted:

  • Comments that assume you already have context on the problem the code is solving.

Oooh, this is a tricky one, and I'm probably guilty of it myself. I find there's often stuff that if you're looking at it in any depth, you need to have some context on the issue at hand already.

Or maybe that's just what I tell myself, and I just write lovely comments...

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

redleader posted:

Oooh, this is a tricky one, and I'm probably guilty of it myself. I find there's often stuff that if you're looking at it in any depth, you need to have some context on the issue at hand already.

Or maybe that's just what I tell myself, and I just write lovely comments...

Depends the level of assumed knowledge of the reader. There are definitely things that a random practitioner may not know that everyone in a sub field should.

If no one will ever benefit from the comment, it’s not helpful.

Then again, that’s exactly the argument maths PhD’s make when authoring whatever thing they’re doing. So maybe the assumed reader should always be a novice.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

leper khan posted:

Depends the level of assumed knowledge of the reader. There are definitely things that a random practitioner may not know that everyone in a sub field should.

If no one will ever benefit from the comment, it’s not helpful.

Then again, that’s exactly the argument maths PhD’s make when authoring whatever thing they’re doing. So maybe the assumed reader should always be a novice.

I wonder about this kind of thing when someone leaves a comment that describes a lesser-known, but still well-documented, facet of a language or library. It may have been a surprise to them, but it wouldn’t have been a surprise to someone more familiar with the language/library.

Can’t think of a good example so here’s a dumb one: someone hadn’t used the ternary ?: operator before so they leave a comment above it explaining // if test ? do this : else do that

I would find that comment actively unhelpful because I’ve internalized ?:. If someone puts a comment like that then I slow way down and reread the code because I assume the comment is pointing out something weird or unexpected. And it was, to the novice.

Like always there’s a balance, but it can happen outside of a specific sub field too.

Ither
Jan 30, 2010

How often do you all ask for raises? Once a year?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Ither posted:

How often do you all ask for raises? Once a year?

I don't ask. I just get them during my annual review. And they're usually good, between 5-15%.

Careful Drums
Oct 30, 2007

by FactsAreUseless

Cuntpunch posted:

I am assuming you're talking about folks who are clearly engaged with the work and otherwise enthusiastic - but just can't seem to give a drat about quality?
I've got a pet theory that this is especially common in software mostly because of the esoteric prestige that comes with BEING A COMPUTER PROGRAMMER! You get folks who love being a programmer more than they really love programming. Who get seduced by the feeling of 'oh gently caress yes everyone thinks I'm a supergenius when I tell them I WRITE SOFTWARE' rather than loving the work itself enough to give a poo poo about the bigger picture.

(Note, this isn't necessarily limited to programming and tech, but I think it's more prevalent here)


Never really thought about it before but I think that idea holds water (and I'm DEFINITELY NOT TALKING ABOUT MYSELF)

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
I can definitely confirm that I was a snotty little poo poo as a young programmer and had to have the ego beaten out of me. So yeah, there's some truth there.

Keetron
Sep 26, 2008

Check out my enormous testicles in my TFLC log!

Ither posted:

How often do you all ask for raises? Once a year?

Whenever I switch contracts.

geeves
Sep 16, 2004


My company's C-Suite in action with our company's product.

Slimy Hog
Apr 22, 2008

New Yorp New Yorp posted:

I don't ask. I just get them during my annual review. And they're usually good, between 5-15%.

Is that standard? My company's engineering department just decided that we need to have 3 standard buckets for raises: 3%, 5% and 7%; no higher unless you're getting promoted.

Slimy Hog fucked around with this message at 19:19 on Jan 16, 2019

Jose Valasquez
Apr 8, 2005

Slimy Hog posted:

Is that standard? My company's engineering department just decided that we "need" to have 3 standard buckets for raises: 3%, 5% and 7%; no higher unless you're getting promoted.

In my experience 3%-7% seems pretty standard if not a bit high for most companies.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
3% is usually a pay cut when accounting for inflation.

LLSix
Jan 20, 2010

The real power behind countless overlords

TooMuchAbstraction posted:

3% is usually a pay cut when accounting for inflation.

3% keeps you just ahead of inflation in USA for the last decade: https://www.usinflationcalculator.com/inflation/current-inflation-rates/ If you live on the coasts it may not be keeping up with the cost of living though. I'm not sure where to look for those numbers.

I agree its not a raise.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Slimy Hog posted:

Is that standard? My company's engineering department just decided that we "need" to have 3 standard buckets for raises: 3%, 5% and 7%; no higher unless you're getting promoted.

It's pretty uncommon in my experience. My company has taken very good care of me, which is one of the reasons why I just finished my 6th year with them. I make 60% more than when I started. And they give decent bonuses. And for some reason, one of our clients gave me an additional bonus last year, although that's never happened before and will probably never happen again.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

TooMuchAbstraction posted:

It also bears mentioning that some of the people contributing software on my team are not formally-trained software engineers. My team does hybrid science/software work, so we have people who did other stuff in college than take three years of software deep dive courses, and their industry experience is at a lab bench rather than a desk. Otherwise, the main issue the team has is that it's very junior.
I found the thing! Welcome to my world, except with electrical engineers.

None of the problems you mention fundamentally matter so long as they don't get all pissy about doing the work. I think it's very rare for somebody to not learn from the feedback and improve, even if it takes awhile, unless:

1. The code is an auxiliary task for them that they don't care about at all.
2. They think they're God's Gift to Software because they aced the lovely programming class they took in college in their major so you're just some rear end in a top hat to them.

I've found if neither of those are a problem, then subsequent submissions will repeat some problems, but much less. If so, then you can help mentor them until they find out all they ever wanted to do was software and they leave to do that instead.

That's my life.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

Rocko Bonaparte posted:

2. They think they're God's Gift to Software because they aced the lovely programming class they took in college in their major so you're just some rear end in a top hat to them.

The best antidote to #2 is failure. Code review is good because it can help prevent people from failing, but nothing breeds humility like failure, and you might just need to step back and let failure happen.

LLSix
Jan 20, 2010

The real power behind countless overlords

TooMuchAbstraction posted:

On a related note, how do you get your teammates to do more rigorous code reviews? Because those not-really-ready change lists are getting a pass from other teammates despite glaring flaws.

The one place I've seen this done well code review was a privilege, not a right. Before you were given permissions to sign off on a code review you had to get all of your code reviewed by at least 2 more reviewers than usual and it had to consistently pass without change requests from any of them for at least a week. When there weren't enough reviewers on the team (common) we'd ask for help from other team's reviewers. Took most devs about 6 months to get to the point where they were consistently submitting mistake free code. New code reviewers were also on informal probation and provided check lists of common issues to look for and were mentored by the other reviewers double checking their reviews and walking them through anything they missed for the first few weeks.

TooMuchAbstraction posted:

This isn't failing to hew to specs. But, uh, some examples...
  • code:
    for x in y:
      if z:
        <entire rest of for loop>
    
    (where it'd be preferable to say "if not z: continue" to avoid excessive indenting)
  • Skipping writing tests, and pulling the old "I'll write the tests after this gets checked in" when they get called on it.
  • Excessively over-extended functions (well over 100 lines long when there are clear points where they could be decomposed)
  • Confusingly-named variables, and variables and functions that shadow other ones in the same scope
  • Lists that should be sets, tuples that should be structs / named tuples, multiple arrays that have to be kept in sync (using the same index in each to access different aspects of the same data) rather than a single array holding a complex datatype.
  • Throwing together six unrelated things into one gigantic change instead of breaking them out into smaller ones.
  • Comments that assume you already have context on the problem the code is solving.
  • Declaring a boolean as foo = False if bar else True. This one always makes me sad to see.

For the most part these don't on their own represent huge problems. I very rarely have to say "no, stop, this is a fundamentally wrong approach." But I end up with like 20-30 nitpicks and requests for changes and clarification even on relatively small changes. What worries me is that they don't seem to be getting better at this: I'm seeing the same categories of mistakes being made repeatedly by the same people.

I dug up a couple of links I think are good external sources I would sprinkle into code reviews to help convince devs that this stuff is important.
Generally style rules: https://google.github.io/styleguide/cppguide.html - You may recognize this one.

Variable naming advice: https://hackernoon.com/the-art-of-naming-variables-52f44de00aad

Some good pithy advice links including my favorite: "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." ― John Woods
http://codewithawa.com/posts/10-most-badass-quotes-about-programming
https://medium.com/cygnis-media/20-fantastic-quotes-to-shed-light-on-application-development-12542402a2eb

Remind devs who are slow to write tests that they'll have to maintain the code later, and then follow through. I like to give devs, especially junior ones, features to own and then make sure they get assigned any bugs or changes there so they can learn from their mistakes.

I don't have a good link handy for devs writing huge functions (If I have to correct it more than I few times I let them do it their way and then require them to maintain it and that cures them quickly enough) but this looks good: https://www.toptal.com/software/single-responsibility-principle

TooMuchAbstraction posted:

[*]Throwing together six unrelated things into one gigantic change instead of breaking them out into smaller ones.
This is one of the easier things to fix in my experience; just don't let big patches get committed. If they put one up for review send it back with instructions to break it up and no other comments. You also said they're pretty junior so you'll have to show them how to do this the first few times. This also happens less if your process breaks projects down into tasks that shouldn't take more than 4 hours. Things explode sometimes, but decomposing tasks before writing any code helps a lot with keeping scope in check.

For commenting I like to say that I can read what the code does, but I need comments to tell what you think it is doing and what it should be doing. It sinks in and eventually they start writing more useful comments. Another trick is to encourage them to write the comments before writing the code. Essentially stepping through what they want to accomplish. I do it myself sometimes when I'm doing something tricky and need to think through an algorithm. Usually gets you cleaner and more efficient code too.

You can find some really good talks that get posted to youtube and other places from Developer conferences. When I was at Garmin I'd take over a conference room every other week and invite any devs who wanted to come watch a talk. Unfortunately I left all the links I'd collected behind when I moved.

Overall though, if those are the worst problems you're seeing I'd say you've already done a great job so far. The only one I'd be upset in seeing in a junior dev is the no tests thing, and several other people have already suggested process improvements to catch that before you or another human looks at it. I don't know how many times I've had to tell people that untested code isn't finished code though. Even if you have a robust QA team, devs should be testing happy paths and any likely failure points because bug's get more expensive the later they're found (there's lots of research on this, but here's a site with a pretty graph https://www.isixsigma.com/industries/software-it/defect-prevention-reducing-costs-and-enhancing-quality/)

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

LLSix posted:

Some good pithy advice links including my favorite: "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." ― John Woods

I don't know if I heard it and then stole it without remembering I stole it, but I've been saying almost exactly that for at least 10 years when explaining to teams why good test automation practices are critical.

Volguus
Mar 3, 2009

Rocko Bonaparte posted:

1. The code is an auxiliary task for them that they don't care about at all.

Had a a guy at my work who was a PhD, a machine learning expert (no idea what exact qualifications he had as i did not hire him). The code that he did write was extremely bad (i learned new ways of writing spaghetti code, i would have never imagined). Now that wouldn't have been a big issue in and of itself, but he did refuse to change. His attitude was always "let Volguus untangle this mess and make it an actual usable component". Well, gently caress you too mister. Finally they let him go last month as he was more of a liability.

To not mention about tests : that was not even on the radar.

JawnV6
Jul 4, 2004

So hot ...

TooMuchAbstraction posted:

I can definitely confirm that I was a snotty little poo poo as a young programmer and had to have the ego beaten out of me. So yeah, there's some truth there.

A couple of your items are only a problem for long-term maintenance and coming from an academic environment where getting it over the finish line by a deadline is far more important, would seem strange. For the more minor stylistic issues, I'd point out where if foo < 1: continue; idiom is used in the code base already. I'd hope the juniors are taking your advice, but when you're telling people "how" to do something it can be important to emphasize the "why" to get it to stick.

I legit don't know if it's possible to land on best practices without, e.g., watching a multiple-arrays-with-same-index solution grow to be monstrous and difficult to refactor. Maybe it's enough to see one fully-formed, with a little bit of history diving to see why each little step towards it seemed reasonable.

return0
Apr 11, 2007
Uncomfortable with how little controversy there was about code coverage; it is bad!

vonnegutt
Aug 7, 2006
Hobocamp.

return0 posted:

Uncomfortable with how little controversy there was about code coverage; it is bad!

As soon as there is a number attached to code coverage you get management trying to reward/punish based on that number. Never make an easily-measured number a proxy for code quality.

Jose Valasquez
Apr 8, 2005

Code coverage is good!

Jose Valasquez
Apr 8, 2005

vonnegutt posted:

As soon as there is a number attached to code coverage you get management trying to reward/punish based on that number. Never make an easily-measured number a proxy for code quality.

If it is enforced at submit then everyone is meeting it so it isn't likely to be rewarded or punished, it is just a requirement to submit. If someone is gaming the system with lovely tests then they are a lovely employee and should be fired

baquerd
Jul 2, 2007

by FactsAreUseless

vonnegutt posted:

As soon as there is a number attached to code coverage you get management trying to reward/punish based on that number. Never make an easily-measured number a proxy for code quality.

If upper management wants numbers, they will get their numbers. It's a reasonable way of differentiating people who know how to play a numbers and politics game versus those who rigidly just want good software. Why that is desirable is a very different and perhaps unanswerable question.

vonnegutt
Aug 7, 2006
Hobocamp.

baquerd posted:

If upper management wants numbers, they will get their numbers.

I've witnessed formerly unconcerned management suddenly get obsessed with metrics once a metric was enabled. Especially a non-tech management when presented with a metric that supposedly measures something un-measureable. And very few people are content to see a number stay the same - they want it to go up. Once it can't go up any higher, then it becomes punishable if it drops. Keeping code coverage at 100% is much more difficult than keeping it at 95%, for very little actual quality gain.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

vonnegutt posted:

I've witnessed formerly unconcerned management suddenly get obsessed with metrics once a metric was enabled. Especially a non-tech management when presented with a metric that supposedly measures something un-measureable. And very few people are content to see a number stay the same - they want it to go up. Once it can't go up any higher, then it becomes punishable if it drops. Keeping code coverage at 100% is much more difficult than keeping it at 95%, for very little actual quality gain.

I'm curious how you get 100% code coverage in cases like this:
code:
object, err := json.Unmarshal("[1, 2, 3]".([]byte))
if err != nil {
  returns errors.New("Welp, I guess our CPU is corrupt.")
}
In other words, technically json.Unmarshal can return an error, and the proper style is to "handle" that error (by propagating it up the call stack, because Go thinks exceptions are bad and therefore you must badly re-implement them with every function call), but in practice the error can't be triggered because you're passing the function a known-valid input.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
A lot of managers are lovely partly because they can’t articulate why things are lovely / not lovely without some straw man numbers to absolve themselves of blame and are actually at the mercy of the teams they lead but can’t act like that’s reality because then what’s the point of you being a manager when some other asshat that acts tough gets perceived as “getting things done” and the concept of servant leader is openly mocked despite high praise from both the metric output and the direct report.

Starts from the top down.

- Former Manager at A Very Publicly Known Bad Company

Paolomania
Apr 26, 2006

Idiotic obsession with high coverage metrics doesn't make coverage bad. My team has an 80% coverage goal (no check in enforcement) and that is easy enough to hit with reasonable unit testing. I have personally found it useful when looking at some graphical lcov output and realizing that an error we thought was covered was actually not covered because the unit test was hitting a similar but different error condition.

JehovahsWetness
Dec 9, 2005

bang that shit retarded

TooMuchAbstraction posted:

I'm curious how you get 100% code coverage in cases like this:

duh

code:
object, _ := json.Unmarshal("[1, 2, 3]".([]byte))

GeorgieMordor
Jan 23, 2015
I was the sole engineer and technical decision-making person at my last job. Was there for over five years. I’m looking for work now as an engineer and having an awful go of it.

Conversationally things go great, and I’m always excited and comfortable to talk about approaches, concepts and open to discussion, questions and challenges.

It’s seeming like I’m not cutting the mustard on technical interviews, even the ones I thought went reasonably well I’m still passed over. I practice for them, brush on aspects and concepts I think will be relevant. During them I'm confident and comfortable explaining my reasoning. But then, nada. Frustratingly, getting feedback on where I was weak and left them deciding to pass are consistently met with crickets chirping when I follow up.

Does anyone here with a hiring position have insight on what I may be doing "wrong"? Why are hiring managers so cagey about giving feedback? I stumbled across this article recently and it's been depressingly accurate.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
My guess is that feedback isn't given because nobody wants to go anywhere near the realm of hiring discrimination, so even if they could accurately say "you didn't get hired because you punched your interviewer in the face and then shat in their coffee" they wouldn't. Much safer to leave it as a completely opaque process that generates results which were unfortunately not favorable in your case.

Interviewing is a skill and takes practice. You're also at the whims of your interviewers, so e.g. just because you passed a question may not mean that you passed it "hard enough" for someone with your experience level. Like, they might have this idea that anyone with over X years of experience ought to be able to solve their pet problem in five minutes. Basically it's a crapshoot. You can influence your prospects by practicing, but you can't guarantee that good interviewing skills will let you pass any given interview.

GeorgieMordor
Jan 23, 2015

TooMuchAbstraction posted:

My guess is that feedback isn't given because nobody wants to go anywhere near the realm of hiring discrimination, so even if they could accurately say "you didn't get hired because you punched your interviewer in the face and then shat in their coffee" they wouldn't. Much safer to leave it as a completely opaque process that generates results which were unfortunately not favorable in your case.

Yeah makes sense. This was my knee-jerk but wondered if I was just being cynical. I'll resign to just wallowing in mystery, though philosophically I feel like a hiring manager *should* be comfortable giving objective answers on how a concept, execution or explanation was weak enough to determine a candidate was not a good fit.

TooMuchAbstraction posted:

Interviewing is a skill and takes practice. You're also at the whims of your interviewers, so e.g. just because you passed a question may not mean that you passed it "hard enough" for someone with your experience level. Like, they might have this idea that anyone with over X years of experience ought to be able to solve their pet problem in five minutes. Basically it's a crapshoot. You can influence your prospects by practicing, but you can't guarantee that good interviewing skills will let you pass any given interview.

Frustratingly it definitely is seeming that way. Any advice on how to practice interviewing specifically? Are there coding exercise tools that are better suited for that than others, perhaps?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

GeorgieMordor posted:

Frustratingly it definitely is seeming that way. Any advice on how to practice interviewing specifically? Are there coding exercise tools that are better suited for that than others, perhaps?

Practice by interviewing. I guess you could also find a collection of interview questions, and then practice by bringing up a question you haven't seen before, then standing in front of a whiteboard and out-loud talking through how you'd solve it, then writing out your solution on the whiteboard. Actually writing code for a bunch of problems (like Advent of Code or Project Euler or whatever) can be a good way to get practice at solving little problems, too.

I know you didn't specifically ask for this, but as an interviewer here's what I'm looking for from the interviewee, more or less in order:
  • They demonstrate that they understand the problem. This includes things like clarifying what exactly the limits on the inputs are and what kind of output I want, and describing some examples and what their expected outputs would be.
  • They talk as they think. Like, "Hm, my first thought would be to use a map to represent the grid edges." Interviewees that fall silent while they think make it hard for me to understand how they're approaching the problem.
  • They come up with a rough sketch of a solution before they start coding. This doesn't have to be written down but I should be able to understand the algorithm they plan on using before they start coding. Interview questions are chosen to not be immediately obvious in how they should be solved, so typically if you dive in and start writing code without a reasonably complete plan, you're going to make mistakes. You have limited time to solve the problem and I have follow-on questions I want to ask, so the less time you spend going "oh wait, actually I need to do this a different way", the better.
  • They can come up with a workable solution in something closely approximating a real programming language (i.e. not completely pseudocode).
  • They can test and analyze their solution by stepping through it and identifying what each line is doing.

Your goal is to convince the interviewer that you have all of the above skills. That involves a lot of talking and maybe some diagrams that you typically wouldn't produce when writing code for your job.

JawnV6
Jul 4, 2004

So hot ...

TooMuchAbstraction posted:

as an interviewer here's what I'm looking for from the interviewee, more or less in order:
  • They demonstrate that they understand the problem. This includes things like clarifying what exactly the limits on the inputs are and what kind of output I want, and describing some examples and what their expected outputs would be.
  • They talk as they think. Like, "Hm, my first thought would be to use a map to represent the grid edges." Interviewees that fall silent while they think make it hard for me to understand how they're approaching the problem.
  • They come up with a rough sketch of a solution before they start coding. This doesn't have to be written down but I should be able to understand the algorithm they plan on using before they start coding. Interview questions are chosen to not be immediately obvious in how they should be solved, so typically if you dive in and start writing code without a reasonably complete plan, you're going to make mistakes. You have limited time to solve the problem and I have follow-on questions I want to ask, so the less time you spend going "oh wait, actually I need to do this a different way", the better.
  • They can come up with a workable solution in something closely approximating a real programming language (i.e. not completely pseudocode).
  • They can test and analyze their solution by stepping through it and identifying what each line is doing.

Your goal is to convince the interviewer that you have all of the above skills. That involves a lot of talking and maybe some diagrams that you typically wouldn't produce when writing code for your job.

Keetron
Sep 26, 2008

Check out my enormous testicles in my TFLC log!


Top quality post, would read again, A++

Doom Mathematic
Sep 2, 2008

TooMuchAbstraction posted:

I'm curious how you get 100% code coverage in cases like this:
code:
object, err := json.Unmarshal("[1, 2, 3]".([]byte))
if err != nil {
  returns errors.New("Welp, I guess our CPU is corrupt.")
}
In other words, technically json.Unmarshal can return an error, and the proper style is to "handle" that error (by propagating it up the call stack, because Go thinks exceptions are bad and therefore you must badly re-implement them with every function call), but in practice the error can't be triggered because you're passing the function a known-valid input.

OK so I have never written a single line of Go but have you considered something like:

code:
object = [1, 2, 3]

Adbot
ADBOT LOVES YOU

GeorgieMordor
Jan 23, 2015

TooMuchAbstraction posted:

Practice by interviewing. I guess you could also find a collection of interview questions, and then practice by bringing up a question you haven't seen before, then standing in front of a whiteboard and out-loud talking through how you'd solve it, then writing out your solution on the whiteboard. Actually writing code for a bunch of problems (like Advent of Code or Project Euler or whatever) can be a good way to get practice at solving little problems, too.

I know you didn't specifically ask for this, but as an interviewer here's what I'm looking for from the interviewee, more or less in order:
  • They demonstrate that they understand the problem. This includes things like clarifying what exactly the limits on the inputs are and what kind of output I want, and describing some examples and what their expected outputs would be.
  • They talk as they think. Like, "Hm, my first thought would be to use a map to represent the grid edges." Interviewees that fall silent while they think make it hard for me to understand how they're approaching the problem.
  • They come up with a rough sketch of a solution before they start coding. This doesn't have to be written down but I should be able to understand the algorithm they plan on using before they start coding. Interview questions are chosen to not be immediately obvious in how they should be solved, so typically if you dive in and start writing code without a reasonably complete plan, you're going to make mistakes. You have limited time to solve the problem and I have follow-on questions I want to ask, so the less time you spend going "oh wait, actually I need to do this a different way", the better.
  • They can come up with a workable solution in something closely approximating a real programming language (i.e. not completely pseudocode).
  • They can test and analyze their solution by stepping through it and identifying what each line is doing.

Your goal is to convince the interviewer that you have all of the above skills. That involves a lot of talking and maybe some diagrams that you typically wouldn't produce when writing code for your job.

This is good advice.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply