Programming Throwdown - Code Reviews
Episode Date: May 30, 2017In this episode we explain how code reviews work and why they are so important. Show notes: http://www.programmingthrowdown.com/2017/05/episode-66.html ★ Support this podcast on Patreon ...★
Transcript
Discussion (0)
programming throwdown episode 66 code reviews take it away jason. Hey, everyone. This is our double for this month because of my illness last month.
And one thing I did last month, even though I was quite sick,
I was able to assemble a 3D printer, which was actually super, super fun.
I went on GearBest, which is some Chinese distributor,
and I ordered a 3d printer kit it was literally just
bags of screws and wires and and rods and and uh like this thing that had been cut out of acrylic
like a bunch of little acrylic pieces and some stepper motors that you could have got just right off the shelf at Fry's or something.
But, you know, it came with the whole kit.
And it was very daunting.
I mean, the thing that scared me the most was at one point I pulled out of the box like a 120-volt, like, plug that would plug into the wall.
And the other end was just three bare wires.
Don't stick them to your tongue.
Yeah, and I just thought, I mean, I'm not one of the people that, like, put paper clips in the sockets when I was younger or something.
And so that whole, like, everything related to, like, electrical work, I just have no familiarity with.
But I just dove in.
I knew that there were going to be a lot of good resources.
And there are just an incredible amount of resources on how to do it. There's tons of videos from different angles, different people doing it. And I built it and it actually worked. It was a little bit scary. The first time I turned it on, smoke started pouring out.
Oh, no. And basically, I had some of the copper strands of the 120 volt had like touched each other and completed a circuit and like melted part of the thing.
But it was okay.
The part it melted wasn't a big deal.
That doesn't sound okay.
Yeah, it was super scary.
I was pretty sure I destroyed it.
I got extremely lucky.
Part of it, too, is as soon as I saw a bit of smoke, I unplugged it.
And, yeah, so that was the first issue.
The second issue was the way it works, if you've ever seen a 3D printer, you have two stepper motors, and you have these two cables that make one makes the platform go towards you and away from you
and one makes the printer head go to the left and to the right but the part that makes the
printer head go up and down that needs to be very very accurate and so you can't have just a plastic
cable for that also you know gravity is constantly putting tension on it. So for that, they have these two metal rods that are threaded, kind of like a screw, but, you know, you're not screwing it into anything.
It's just two cylinders that have a thread.
And they plug into two stepper motors, and they both turn kind of in sync.
And so the idea is when you turn both of these screws together it kind of
makes this whole kind of platform rise up and when you turn them the other way it makes them
makes it rise down um and i guess those rods needed some wd-40 or some grease or something
and so i didn't do that um and uh you know like there's just like the friction was causing
everything to get messed up.
It wasn't, you know, the left and the right side weren't rising up the same.
Um, so there's basically long story short, there were several times where I felt like
I was out the $220 and I felt like it was just, uh, like, you know, I tried it, it's
ruined, you know, whatever, you know, I, I kind of like, I felt kind of bad about it
cause I wasted the money. Um, uh, but then in the end I finally got it to work it was just super super
satisfying so what have you been making yeah so I printed a couple of things just to make uh just
like some functional things um like I printed something to hold my watch um like on the dresser
and things like that I also I had this crazy idea that I've had for a while
and I finally got to implement it.
I went on Thingiverse and I found models of lions
and bears and other animals.
And at first I 3D printed them
and my son got to play with them
and he thought it was super cool.
And then I actually went in Blender,
which is a 3D editing software, and I sort of detached the head.
I decapitated all of these animals.
And then I made the head screw and the body like a thread.
And so you can actually screw off the lion head and screw it onto a bear body.
I did it kind of haphazardly. So when you screw the head on, it doesn't screw on
straight. So all the animals look like they're kind of turning their head, like they're all
looking over their shoulder. But it's still really fun. And my son and I, we got a huge kick out of
it. That's pretty funny. Yeah, it was great. I highly recommend doing it, especially if you're
like in high school or college
or if you don't have a lot of experience with electrical stuff.
This is a great way to get started.
It was something that actually worked, which is for me and mechanical things, that was a rarity.
Well, except for that part where you almost burned your house down.
That's true.
Yeah, be really careful of AC mains voltage out of your wall.
It's no joke.
Yeah, yeah, that's true.
I mean, I was pretty sure that I was going to destroy something
like fundamental in my house, and I was pretty close to doing that.
All right.
Don't do this without supervision.
If you're in high school or something, have your dad help you
or your mom help you or have a friend over, someone who could put it out with a fire exting high school or something. Have your dad help you or your mom help you or have a friend over,
someone who could put it out with a fire extinguisher or something.
Words of endorsement from Jason.
All right, well, time for the news.
My first link is the Competitive Programmers Handbook.
This is a PDF compiled by someone named Antti,
or yeah, I guess Antti,
and I won't attempt the last name who compiled
a whole bunch of tips and tricks and algorithms for the kinds of things you would need to be able
to do if you wanted to do competitive programming now you may say well competitive programming is
starting a company and competing against all the other people starting a company in order to do
better but competitive programming i think in this context,
refers to programming competitions
where a bunch of programmers gather together
and get assigned puzzles and problems
and a time limit in which to solve them.
And the sort of fastest to be able to solve,
roughly, to solve the problems is the winner.
And there's a sort of points,
sometimes based on the difficulty of the problems, the exact
structure of the competition can vary.
But sometimes I think I did a couple of these when I did my computer science stuff in high
school.
I think like my senior year maybe, but I think most people get experience with this in college.
The ACM, the Association for Computing Machinery runs a really big programming competition
each year.
Yeah, I mean, the thing to keep in mind is that, like, there's sort of this, like, family of people who compete and then grow up and, like, grow older and become judges and then become problem writers. And so, you know, it means that there's like a specific niche of computer science
that's going to cover like 90% of the problems that you see in competitive programming.
And so even if you might be a super strong CS student,
but you also have to study the competitive programming world
because it dives really deep into a handful of areas and doesn't cover other ones so right so
and sometimes the the problems can be quite tricky the sort of most obvious solution will definitely
not work and you need to understand sort of why it won't work and figure out what they
what the trick is to it and in that way it becomes a puzzle puzzle. Yeah, yeah, absolutely. Yeah, I also, I did a bunch of these programming competitions in college.
I think it's great.
It's a great experience.
But yeah, as I said, there's sort of this hidden like gnosis around it.
And so it's really important to study.
And this is actually a great resource because it really covers it in a lot of detail.
And it's a great way to kind of get familiar.
And a lot of the interview questions at companies, you know, kind of are modeled after competitive programming assignments because mostly because of the time limit.
You know, like you have maybe an hour to solve a problem in a competitive situation,
and you have an hour or even half an hour to solve a problem in an interview. And so they
kind of end up converging a little bit there. So this would also help, you know, your interview
skills. Yeah. And I think also just becoming comfortable with a lot of the algorithms that
are necessary for the programming competitions are really helpful for the interviews as well.
Yeah. Yeah, totally. Like for the reasons you said,
the kind of depth you get into
is about the same between the two
because you just don't have much time
to kind of write well architected code per se.
It's mostly about sort of getting to the,
coding the algorithm.
But I will say most of the things in this book,
sort of especially the later half,
are things like it would be awesome to understand
and to do well in programming competitions
are probably needed,
but you would be unlikely to encounter these
on a programming interview
unless it was a really tough interviewer.
Yeah, yeah, exactly.
I mean, a lot of, I would actually be surprised
to even find really any dynamic programming
and things like that in an interview.
But yeah, I mean mean these are like super advanced
things but definitely a great resource and if you're interested in or are currently doing
programming competitions check it out also we do recommend um oh i forget the name of the other one
but top coder is a website that has uh programming competitions and there's also and uh hacker rank
is another one and and so those are also good resources to gain practice apply the knowledge knowledge you learned from this book, that kind of stuff, but also to prepare for programming interviews.
We get that question a lot from listeners.
Yeah, actually, I helped someone about a month or two ago.
And he asked me for help interviewing at a company I used to work at.
And I told him, I said, let's just, you know, open up HackerRank and start solving
problems. And I still think that's the best way to go about it. And if you don't have a lot of
experience with competitive programming, then chances are, even if you're really good at CS,
you're going to have a hard time with something like HackerRank, which is kind of the point.
Like, it's good to see, you know, what sort of knowledge gaps there are and and there's
great documentation most of the these sites give you the answer along with an editorial and things
like that so cool so I'm going to talk about C++ 17 and so I'll give a link to it a lot of new
features a lot of cool stuff coming out it's amazing because I remember C++11 being just super, super delayed
and having to rely heavily on boost.
Like if you wanted even just threading, you had to use boost.
And I think C++11 was originally supposed to be C++08, if I remember correctly.
We could probably find out from our old episode.
It took till 11 to get it out the door.
But now here we are with a 14 and a 17.
And it's actually almost, you know,
getting to the point where unless you're really heavy
in a C++, you can start to lose track
of the latest features.
But yeah, there's some really cool stuff here.
And we've provided a link so you can kind of check it out,
like the latest and the greatest C++ stuff.
I feel like we should enter into a segment
where we discuss our favorite feature from the new...
No, I'm just kidding.
I mean, the one I use the most,
I mean, this is covering all of the extensions,
is the totally...
I totally forgot.
I think it's called the range operator.
Basically, it's where you do like-
List comprehension?
Is that what it is?
It's where you do like four X colon vector
and then it saves you from having
to write the whole for loop.
I call it list comprehension,
but I don't know if that's the right term.
Yeah, there's a bunch.
I know it's called that in other languages.
Yeah, that and the threading.
Like going from boost threading to just a C++ threading
is literally just changing.
It's a regex, right?
But I had a bunch of code and still have now.
I'm producing a bunch of code that uses threads.
And it's good that that's just baked into the language
because it's so important.
The other thing from C++17 that's nice
is they're continuing to support sort of extra features
in the const expressions.
So if you write a lot of const expressions,
which can be compiled time evaluated,
before it was very strict what could be in them.
And now there's increasing things
that are added to the list of what can be in them,
which is good.
Cool.
Yeah, doing more like type inferencing.
So my next news article is called Simple Chess AI.
This is an article that was posted on, I guess,
somebody's Medium platform, Free Code Camp.
Anyways, we'll have a link in the show notes.
And I came across this, but it was really interesting
because a lot of people, well, you know, of course,
artificial intelligence is in the news a lot.
And it means lots of different things to lots of different people.
So I don't think there's any neural networks or there are no neural networks in this example. and have it already set up for you to kind of plug and play your sort of move evaluator,
the opposing player, the computer player.
And I thought it was really cool because I've always, you know, thought to myself,
like, oh, I should make a, you know, chess bot or something that plays chess.
But then it's always like the setting up a representation for the board and having a visualizer.
It's a lot of work to get to the thing you're trying to do.
And so I thought this was a particularly compact setup.
I probably could have gone and found, you know,
something at some point if I had been serious about it.
But it comes along with the tutorial
where they take you first amount, you know,
simply being able to make valid moves,
then being able to, you know,
talk about what the tree of possible moves would look like
and how to evaluate that.
And then how to prune that tree so
that you can go farther down the tree which means in this case farther down the tree is further into
the future of potential moves and that way the more you can trim as these paths aren't good
then the farther down you can go the farther in the future can look and the more sort of
predictive your engine becomes and being able to be a little more strategic
than just tactical.
And then, you know, sort of how do you have heuristics
for the relative point values of the pieces?
Or what about different pieces are more or less important
depending on where they are on the board?
And how do you sort of encode that?
It goes for a lot of it, actually.
I mean, I'm not a great chess player,
so I'm pretty sure that AI that ends up by the end
could probably beat me pretty handily.
But I thought this was a very kind of interesting introduction
on how to do sort of game AI.
Yeah, totally.
I mean, even just a player, like a simple heuristic like this
with an eight-move look ahead will make an expert player
that would beat almost everyone who's not a competitive player.
Yeah, chess is hard yeah just a hard game to play but go is harder so that's right i guess we should
really be upping the limit here in writing simple go ais that's that's hard to do um yeah the thing
about chess is you can you know even eight moves ahead or six moves ahead you can exhaust all the possible
actions with this pruning in mind um but with go i mean you know at every board state you have
hundreds of actions yeah the branching factor is much higher yeah exactly right all right so we'll
put that in the show notes so i'd check it out if it sounds interesting yeah this looks awesome i
mean it's as as patrick said step by step so so there's
there's nothing stopping you from uh from from coding this up yourself um and reading just by
following this tutorial and having some understanding of like a python or c++ or something
like that i know another classic example people do are make the worst possible chess ai so make an
ai that loses as fast as possible oh really did you see the uh
worst overwatch player article no so basically i mean it's a little bit of a tangent but uh
um overwatch had a formula it's probably some variant of elo or something to to decide people's
rank um but it's a it's a formula it's's not like the top 10 people, top 10% of people are rank one,
so on and so forth, right? It's not like that. And so there's the worst, I think the worst rank
is rank one. So I think one is the lowest. And there's a person who he made it his personal
mission to get to rank one. And people had thought it wasn't even possible and uh he basically
you know he actually like walks through like in the beginning he's playing with pretty competitive
people because i guess originally like initially he was really good and the people were like pretty
mature and and and nice and and you know he was losing all these games um and then he got to like
the middle and when he got to about a little worse than average
the people became trolls so basically like all the trolls are the people who are like slightly
worse than average that's like where most of the trolls are and then when you get even worse it's
a lot of bots it's people who are have just written scripts to play the game or not even
play and participate in the game so that they can get the loot afterwards and he had to like lose the bots which is really hard to do so he spent a ton of
time like trying to force himself to lose and he did eventually get to rank one but it's it's a
really cool story but isn't that sort of a that described that hierarchy that's i guess i've been
on the bad end of that which is coming into a game not when it first comes out but you know after a little while and people have been talking about it and i sort of say i'll check this out
but of course you come into it as sort of a worse than average player you know hopefully and uh yeah
then what happens is you start playing and you're sort of playing with the people like you said who
are the trolls who just go from game to game or whatever and like being the worst and there may
really be a good community above that but you never really get to experience it
because you can easily get turned off of the game
by the kind of bad experience at the low level.
Yeah, I mean, that's a real problem.
It's just hard to know how to solve that.
But yeah, that's, I mean, maybe, you know,
maybe the way to solve it is to have some kind of hybrid game
where, you know, you could have a mix of good and bad players,
and the bad players don't ruin the game for the good ones.
But you'd have to design the whole game around that.
Yeah, interesting.
Yeah, but in the meantime, you can tell if you're really in a slump in a game because people start becoming really rude.
When people become really rude to me in Rocket League, I know that I'm on a big losing streak.
So my article is actually, so a security enthusiast found the kill switch for the WannaCry ransomware.
And I'll kind of cover all of this
um and i don't have all the details actually patrick you probably know a lot more than me
on this but uh wanna cry is this uh it's some kind of trojan or virus but uh basically it
takes over your computer and then you have to pay you know bitcoin like anonymous money to an anonymous source to get
your computer back and it spreads through some way that i haven't looked into i'm assuming it's
some kind of maybe over email or facebook or something and the thing about it is i guess
when the person was testing it or maybe just as as a kill switch for themselves or what have you, there's a certain domain name.
And it's a nonsensical name.
It's www.andthenabunchofcharacters.com.
And he would send a request to that domain name, a web request.
And if it came back with a certain response, then the virus
didn't activate. So even though you had the virus on your computer, it wasn't doing anything.
If he sends a request to this domain and he doesn't get anything back, then the virus kicks
in. It locks your computer down. It also tries to spread the virus, so on and so forth. And somebody who was looking at the virus,
you know, decompiling the virus executable, found this logic. And so he went ahead and registered
that domain, which is by itself surprising. Like if you were a hacker, why wouldn't you register
this domain already, right? But I guess maybe that would incriminate you but uh this person registered that domain and he had it return the appropriate result he built his own web server
that did that and he basically stopped this virus which is remarkable yeah it's still unclear why
the stuff had that kill switch in it like why it was doing that there's like a lot of speculation um but yeah
i guess the the person who did it originally wasn't sure what would happen because the code's
complicated but he he did it as an experiment and noticed it sure enough it stopped the code from
work like it stopped the virus from installing itself from uh ransom from encrypting the
computer and and putting up the ransom message yeah yeah, yeah, exactly. I mean, the only thing I could think of is,
you know, it's very hard to sort of test viruses.
That would be my guess,
because even if you're in some kind of virtual machine,
you probably have to log in with some kind of credentials
and especially when you get to testing it on other machines.
And it probably wrote this as a way to keep from
accidentally locking themselves
out of their own computer but yeah i mean i guess for whatever reason they chose or maybe just
forgot and they didn't take it out and and uh um saved a lot of people a huge headache i wonder
how many people have attempted to write ransomware and ransom to their own computer yeah i know right
my guess is probably not that many you have to be pretty
skilled so you probably know to be really careful yeah exactly i mean i feel like the virtual machine
can emulate things so well that there's not really a reason to do it but i mean it could be the kind
of thing where you know yeah if you're careless even once you're totally hosed or maybe you just
pay yourself a bitcoin it doesn't matter oh there you go that's true until that code's not working right and then yeah yeah i i don't i don't
know i always wondered like do the worms and viruses like are they pretty well tested or not
really because like if it's not well tested you have a problem because it sort of gets out and
then people will patch their systems and you may not accomplish the goal you want because you have
unintended consequences or takes down your server that's supposed to be doing whatever
but then if you test it really really really well like do you really care if 10 of people's
computer crash instead of doing what you want right yeah i mean it's at the end of the day
doesn't matter uh well but then it actually gets back to our chess AI example.
Like the branching factor becomes really, really important.
And so even if 1% of people don't spread the virus,
it ends up having a huge impact.
So yeah, my guess is probably they're tested pretty well.
But the question is really like...
Oh, sorry.
Oh, go ahead.
I want to say it's sort of different though.
Well, I get off on a tangent,
but it doesn't matter the order of people being infected per se.
Like if you don't spread it to me,
but Bob spreads it to me,
that's just as bad for me.
Like I don't care that it came from you or Bob.
Yeah, yeah.
I guess the question there is then like,
what is the density of that graph?
Like if I don't spread it to you,
what are the chances someone else is going to know you
or something like that?
But yeah, I mean, actually the real thing I'm curious about
is who are these people?
I think in general, it's usually state sponsored.
Like it's government programs of various countries
that are doing this.
Well, I think Microsoft came out, if I recall,
because it was, you know, it was on Windows
and came out and said that this was a result of, I think,
one of the WikiLeaks or something that revealed the cache of hacker tools
that were used.
Oh, the NSA thing.
Yeah.
We actually talked about that like two shows ago.
Yeah, and they found that apparently whatever this flaw was found in there,
and so people exploited it to make this.
Or at least that was the accusation.
I don't know enough and didn't read enough about it to know if that was sort of proved out or accurate but gotcha yeah i
read something uh yeah i read something along those lines um so yeah i guess uh i guess that
that uh those leaked tools were legit maybe not from the nsa or whatever but at least they were
uh it's definitely they were powerful tools there's no doubt about that time for a book of the show
book of the show my book of the show is very limited time so uh definitely jump on this
um let me see how many days are left uh uh there's probably by the time this show publishes
there'll be about a week left so um jump on this quickly. It's the Humble Bundle for
Make Essentials, for Maker Faire. So basically, it's just a ton of books about building stuff.
So there's books all about getting started with 3D printing that I probably should have read
before I burn my house down. There's books about, you know, designing a good workspace, how to make
3D models that you can then print. There's all sorts of like electrical, you know, like robotics,
like build your own robot kind of thing, microcontrollers, Linux. And you can get a ton
of books. You can actually get a ton of books for a dollar total um if you pay eight
dollars you get twice as many and if you pay 15 you get three times as many uh books um but yeah
definitely check it out it's an amazing deal all of these humble book deals are phenomenal
i just still have problems i guess ebooks have never really clicked with me. I've read a couple, but I get too distracted.
Oh yeah. I, uh, uh, yeah, I'm thinking about it. Like my, the fiction eBooks,
I've definitely read a bunch of, as far as like eBook references. Um, yeah, you're right. You know, I have, I have a decent amount of eBook references, but, uh, um, I don't read them,
read them too much, but maybe it's's just I don't read reference books that much
unless I'm really stuck.
Well, my book is a massive tome of fiction
called The Way of Kings by Brandon Sanderson.
And this is book one of the Stormlight Archive,
which is if I previously recommended the Mistborn series
and it turns out I didn't actually know this at first,
but the Way of Kings is apparently in the same book literary universe. I don't know how you say
that. So it's not sort of, the books don't, at least as far as I know, don't really have anything
to do with each other, but they exist in sort of the same ecosystem of stuff that Brandon Sanderson
calls the Cosmere universe. So I don't know. So there's sort of magic in the books
and the magic isn't the same as that from Mistborn,
but it kind of is similar in a way.
There's also another book called Elantris
that is apparently also set in this sort of Cosmere mythos.
But all that's to say that it's by Brandon Sanderson
who I've recommended several times
and I think he does a really good job of writing.
This book is very long.
I actually, I don't know how long it is in pages because I listened to it.
But the listening to it, I believe it was, I should have looked it up right before I did this.
But I think it's like 30 hours, I want to say, or something like that.
So it's definitely lengthy.
Oh, no, i was completely wrong
it's 45 hours for almost 46 hours well that's like four times the size of a normal book 46 hours yeah
so it's definitely a big book let's see if i can figure out how big the hardcover is um so it's 46
hours very long but i really really enjoyed it in fact i have a bunch of other books and i wanted
to go get the second book
just because i was so into it but i was like after i've been burned before after listening
to like 45 hours straight to go into another 45 hour book it you kind of get a little burnt out
by the end and so it's best to sort of 180 pages ah yeah big um but i definitely recommend it if
you're into long form fiction at least if you do mostly sort of short stuff.
Maybe this is not the best first book because it's quite long.
But if you like sort of long, I actually like really long form science fiction and fantasy.
I'm in the middle of another very long book by Neil Stevenson, and I'm enjoying it, although this one is starting to drag.
So I'm not sure. Maybe I need to go on to a short book kick but anyways the way of kings i know i didn't say anything about what it is because
i never know how to talk about stuff without spoiling it um so it totally makes sense check
it out it's a fantasy book i guess i mentioned there's some magic that's good i could read like
the the back page but you could just do that for yourself on the internet but if you like brian's if you like brandon sanderson or you like fantasy and you have probably already checked it
out because the book is like five years old i think at this point um but if you haven't i give
it to my recommendation very cool and you can uh listen to that book on audible and audible is also
a sponsor of programming throwdown you can go to audibletrial a sponsor of programming throwdown. You can go to audible trial.com slash programming throwdown and you know,
sign up, you get a month free, you get a free book.
And if you use that special URL, then you help out the podcast.
And I will say 46 hours seems to be a good value for me for that audible
credit.
$15 for 46 hours. Yeah, definitely um i'm actually reading a book
i won't spoil it uh but um about a third of the way done um and i actually read some books that
patrick had recommended in the past on audible since i got my account i read a zero to one um
and a couple other books and i think it's. I've actually switched over to that. I can kind of rest my eyes when I'm on the shuttle.
Nice.
So do you go back to the old show notes and look at my recommendations?
I didn't know you were doing this.
I feel complimented.
That's exactly what I did.
Yeah.
Have I been a good recommender?
You have.
Well, you know, I've read some of your recommendations already just on eBook.
But, yeah, I picked up some of the ones that you recommended
that I hadn't already read and got them on audible but yeah in general i like your recommendation
i'm not into into sci-fi so i don't usually uh read the fiction books but uh but uh uh but yeah
i feel like your recommendations are solid super interesting um we're also on patreon so you can
go patreon.com slash programming throwdown um you can give us a shout out, send us a message.
You can also set up a donation,
like become a Patreon to Programming Throwdown.
We really appreciate that.
At the end of the year, every year,
we take any money left over after our server costs
and everything else.
And we give out free t-shirts to people who are subscribers.
And yeah, check it out.
We also publish a separate rss feed
there that's has a bit more bandwidth so if you're a subscriber um you can use that rss feed yep
time for tool of the show okay so my tool of show has a bit of backstory um while i was buying this
3d printer from china i also noticed china has a bunch of other stuff for sale that is super cheap.
You fell down a rabbit hole.
Yes, it is a rabbit hole.
And I bought a tablet.
I've been wanting this for a long time.
I've been wanting a gigantic tablet.
I wanted a tablet so big that I could read an 8.5 by 11 research paper, you know, at scale.
That was the goal.
But I don't want to spend a lot of money.
I could get like an iPad Pro,
but I think it's like $1,200 or something for the big one.
Or maybe it's like $1,000, but it's still a lot of money.
So a Chinese dropshipper was shipping a 12-inch Android tablet.
It actually runs Android and Windows. What? what it's dual boots yeah isn't that
wild when it starts up it has used the volume up and volume down button to choose whether you want
windows or android whichever you're feeling that day yeah and it's amazing un-freaking-believable
and it was only 200 oh wow this huge tablet, this beautiful screen. The only
catch, it runs
a fork of Android, and
if you just put stock Android on it,
the touchscreen doesn't work.
I saw that from reading
the internet. So I have to leave
the version of Android on, and it also
has Chinese spyware.
So it had this thing called
AdOps that I've read on the internet.
I haven't verified, but according to the internet, it logs your keystrokes, like your keyboard touches.
So when I found that out, I was super bummed.
I thought I had this paperweight, or at least I was going to have to highly regulate my usage.
But then I found this app called, this program called Deep Loader. So you run this on your desktop with an Android device plugged in. And even the factory level services, you can turn
them off. You can't uninstall them because you don't have root access, but you can disable them. You can disable their connections to internet, you can turn them off. You can't uninstall them because you don't have root access, but you can disable them.
You can disable their connections to internet.
You can turn them off entirely.
And so I ran this dbloater
and I turned off add-ups on my tablet.
And the other thing I found out is
a lot of these lesser named brands,
like the BLU, Blue Android Phones,
and some of these other Chinese brands, which
have sold just millions and millions of devices in the US, have this spyware on them.
And so if you have, you know, if you have one of the major ones, like if you have a
Motorola or a Samsung, you're fine.
But if you bought, you know, either for yourself or for your family, one of these like other brands like Blue
or, or, uh, uh, Chewy or one of these Chinese brands, then, uh, run this deep loader or even
if you didn't run the deep loader. And, and, uh, and I think all Verizon phones also have
some type of logging system, um, that it doesn't log keystrokes like it's not that invasive but you could you
could disable it with this program so have you been reading research papers on your gigantic
tablet i have yeah it's actually it's really nice um i have an app called moon reader it's
kind of expensive it's like five bucks for a pdf reader so you So it seems kind of like a waste, but it's amazing. It lets you annotate on the PDF pretty easily. It'll actually switch to night mode and it'll invert the colors
of the PDF. So even the pictures, the colors will be kind of inverted. And yeah, it makes the
pictures kind of strange, but for a research paper where you're really just looking at graphs, it's
okay. And that makes it much easier on
their eyes and everything so yeah it's uh it's it's really nice my tool of the show predictably
is an iphone app i don't actually think well i i should say an ios app because i know it's on the
ipad as well but i don't it didn't look like it was available at least not yet for android devices um and this is card thief
this is by the same um person company that created card crawl which i think i've recommended before
uh if not it's also a cool game check i think it's a couple dollars and card thief is a strategic
card game oh no it does say it's on Android. Okay, cool. Yep. It's on Android. All right, cool I feel bad didn't wanna leave those people out
Anyways, so this this is a strategic card game where you are sort of a thief sneaking around
Buildings trying to avoid lights and guards and trying to get to the exit all by sort of managing
Your stats so that you can get good scores, pick up loot, all that kind of stuff. And I thought it's just sort of fun to see a card game that –
I have several implementations of real card games that I've played,
but it's interesting to see people playing –
simulating playing a real card game,
but in a way where it would be like this card game would never exist in real life
because it would be too tedious or too much bookkeeping
that no one would ever really want to play it.
It's just sort of an interesting genre.
And anyways, yeah, check out Card Deep.
There's other games as well that I play
where I didn't like the idea of it in a real board game
where I'd played things similar
and just like sort of the tediousness of it
made it not interesting to me.
But then playing on the iPad,
you can sort of sit down and it like shuffles for you.
It keeps track of all of your statistics and make sure you don't sort of break the rules by
accident so some games that are really fun but sometimes are sort of easy to mess up or make
great ipad or i i mean just great app implementations yeah totally yeah especially like
agricola and these games that have just so much going on so much more fun on the ipad but it's
so fun to move all those bits of wood around in Agricola.
I don't know what you're talking about.
The app doesn't do it for me.
I don't know why.
It's just like I love moving the little bits around,
but it does make it hard to get to the table.
I actually think, yeah, if I just had an app
where I could take a picture of the board at the end
and it would kind of like a score, that's all I really need.
Fair enough, fair enough fair enough
alright well time to talk about
code reviews this is going
to be an exciting and most thrilling
topic ever
this is I think the interesting
thing about this is you know if we talk
about let's say Python
you're going to learn it in college
or maybe even in high school
and you're going to learn it in college or maybe even in high school. And you're going to go into your first software engineer job,
probably already knowing Python.
But this is something that, like, it's a chicken and an egg.
Like, you can't really know it until you've done it
or until, you know, someone kind of covers the whole process.
And a lot of colleges, you know,
we had a college course called software architecture.
And it was, you know, it really should have covered things like code reviews, but it didn't.
So we actually didn't really get a taste for, you know, code reviews and merging and releasing code and these things until we got into industry.
And so hopefully Patrick and I are going to change that right now.
Yeah, I guess I knew it existed.
But, you know, anyways, I didn't really know what it was.
And it's actually surprising to me.
A lot of people, a lot of companies don't have good code review systems or aren't even practicing code review, which is kind of crazy to me.
So I felt like this was a good opportunity to talk about, yeah, there's a bunch of reasons why you wouldn't want to do it, but there's a whole lot more reasons why you would want to do it and i personally like at this point feel that if i don't get code review
i feel like i'm not done yet like i i feel like you're not done until you write at least some
amount of unit tests and uh and get code review yep totally um anyways so i already was talking
about implying why you would do code review so one of them is get someone else to look at your code.
I mean, there's a lot of times where I've written things that were sort of bad assumptions
and even kind of past unit tests because I also wrote my unit test from the sort of same
point of view.
And someone else will point out like, what in the world are you doing here?
And it's really important to get another pair of eyes for, for several reasons.
One,
you just,
you can miss stuff to,
you know,
as a engineer,
I feel like it's,
and I was describing this to someone is like,
I feel like good engineers are very,
very open about what they do.
They don't try to keep secrets.
They don't try to keep hidden kind of like methods.
They are very open,
very sharing.
And part of that is that way.
And this sounds bad,
but everyone can share in the blame, which is like when something goes wrong, it's not just the person who wrote the code's fault.
It's the process's fault.
It's the people who reviewed the code.
And that sounds like you're trying to look for ways to blame other people, but it's not.
It's about it really, some of the stuff we do is almost too important for just one person to be doing.
And so really you need to have
more sets of eyes on that and code review is a is a great way to do that and have a understanding
about the process of going from writing code and getting it deployed and shipped um and so yeah and
i mean also people want to do different things i mean if you if you keep this you know chunk of
code to yourself then you have to be its babysitter for as long as you work at that company.
Well, some people see that as an advantage.
Yeah, we're talking about good soft pages.
I don't know.
I've been hard-pressed to find a situation where that was truly good.
Yeah, I mean, there's people who say, oh, you know, it's job security if I'm the only person who knows the code base.
It really doesn't work that way.
Like, it's pretty easy to rewrite stuff from scratch.
It might not be easy, you know, for a person to do it, but for a company, it's pretty easy.
And it's much better to, as Patrick said, yeah, be open and write the best possible code rather than try and optimize for job security.
Yeah. And along exactly the same lines is you really want to be able to, you know, it's the, you know, bus insurance. It's like if someone on your team walks out and on the way home and gets
hit by a bus, you want to make sure you know what they're doing. And one of the good ways to do that
is through code review, because other people on the team will be seeing the code that that person
is writing and, you know and understanding what they're doing.
Also sort of prevents people from just kind of not ever paying attention to what you do.
And so make sure that people sort of have visibility into the work you're doing,
good or bad, but hopefully the good work that you're doing.
And so they can kind of like help recommend you
when performance reviews come around or whatever.
Yeah, makes sense.
There are some definite caveats so things where code review can go wrong so one of them is you can get people on your team who for one reason or another uh you know
like to slow things down or they want to land something you know they want to check in some
code before you get it in and so they start to try to be kind of a roadblock.
And one of the symptoms of this is people who get really, really nitpicky about very, very small things like the grammatical structure of your comments.
Or in code review is not the time to decide whether your company or your team is going to use tabs or spaces.
I mean, those code reviews do not work well for those things um those should be decided i guess we call it side channel or
outside of the code review system um code review is also not a good time for like architectural
work at like a big level that should also be communicated in an external way when you go
time to have your review your code review people should already know sort of like the context of
your code um now there may still be needs to critique some of the architectural decisions
at like a tactical level on your code but not you know people should know why you sat down to write
that code for the most part right totally um the other thing is you know the team has to be
diligent about code reviews equally because if some people are really into it and some people
aren't you can end up with a problem of like the very eager person has code out for
review but nobody else is eager about it and so they don't do the reviews in a timely manner
and then that becomes a problem for various reasons and it's on the same token like on
some teams i've been on it's sort of one or two people are very passionate about sort of code
cleanliness and code health and they end up doing sort of the vast majority of the code reviews or have to be a part of all
the code reviews. And there's a bunch of other people who don't do it. And I find that to not
be good. That never ends up working well in the long term. Yeah, that makes sense. I think,
yeah, to have a good code review kind of process, you have to have a good auto formatter. Because
yeah, I've seen so many
code reviews devolve into like oh add a space here put a comma here and and uh you know that ends up
wasting like a lot of human time when you could have just written a program and some regexes and
and you know or used clang format or something um so, if you don't have an auto formatter,
then that should be your first priority.
Or at least a linter.
Yeah, that's true.
Or at least a linter that won't let you
even start the code review
without passing all the style checks.
And then yeah, as Patrick said,
the code review is really,
if you think that the whole architecture
needs to be overhauled, that's a separate task. The code review is really, you know, if you think that the whole architecture needs to be overhauled, that's a separate task.
The code review is really, you know, is there a bug that this person didn't see?
Or are they, did they introduce a bad architecture that's going to sort of spiral out of control that, you know, just materialized in that code review?
But it's not the place to say, oh, you know, I realize maybe we shouldn't have pointers anymore.
Like that's not the thing you deal with in a code review.
Definitely, yeah.
So, you know, one, there's many different ways to do code reviews.
At the end of the day, you know, they all involve kind of, you know, soliciting feedback and receiving feedback.
So it's really they parallel sort of the way you communicate.
I mean, you could just, a simple way is to just zip up your code,
email it to someone, and they'll email you back some feedback.
You could also go in person.
Like, you could have, call someone over to your desk and just kind of,
and I've actually done this, even at companies where we had good tools.
If I see that there's some kind of back and forth
and it's not really going anywhere,
then I'll just go to that person and I'll say,
hey, can you just come to my desk
and we'll just in person, we'll step through this.
Yeah, I do that same reason.
Like if I feel,
not if something's gonna be contentious per se,
but like if I think something is gonna
potentially cause a bunch of questions,
I'll bring people over in advance
and sort of,
you know, walk them through and solicit the suggestions in person.
Yep. Yeah, totally. In person is actually really, really useful. This is kind of a side note, but if ever, you know, an email thread, let's say goes back and forth between the same two people,
let's say more than twice, then you need to schedule a meeting. And the same is true for code reviews.
Like if you say, oh, I think it should be.h, and the person says, no, it should be.hpp,
and you say, oh, well, here's a link to Stack Overflow, or they say it should be.h.
At that point, it needs to be done in person because those just don't really end well.
And then last, they have a ton of different web tools they're super
powerful this is this is the recommended way to do 99% of code reviews I don't
have a particular preference fabricator is a good one Garrett is another one if
you're using github the private gith, or if you're doing an open source project, or using the GitLab or Bitbucket or any of these tools,
they have often a code review tool built into the whatever source control tool you're using.
So that's good as well.
At a high level, the web tools break down into two categories.
One is it's basically just a better way to do the email version.
Like you would send someone a link.
They could click on the link.
They could see sort of a graphical view of your code.
They can make comments right there.
But it's basically the same as the email.
The other way, you know, the GitHub way is where you actually make a merge request.
And this sort of combines the code review with the kind of merge itself, all kind of in one step.
So someone's approving the quality of the code and also the fact that this code belongs in this code base right now.
And I think both are equally good.
So I think there's 100 ways to skin the cat,
but the important thing is to do the code reviews.
I will say that having some sort of web tool is enormously helpful.
I've been in a couple teams mostly a while ago.
I think there's become better support for it recently,
but where in-person code review
used to be the way to do it
and everyone was expected to read the code in advance
and sort of come with a set of questions or comments.
And just like the sheer amount of bookkeeping
and lack of desire to go through the code in advance
really makes it a drag where I really felt
the quality of code reviews was much poorer with that approach.
Now, as Jason said, using in-person, yeah, using in-person to
supplement, yeah, definitely. But as like the only way, yeah, I'm not so sure. Yeah, yeah, totally.
I think, you know, 90% of code reviews should be done, yeah, either email or with one of these web
tools. And the web tools are far faster. Most of them are integrated with your source control.
So some of them them you literally just type
in a command and boom the code review is done like type in a command with a few people's names
and it does all the work for you um so you know part of this is if you're uh you know running
your own company or running your own team you have have to, you know, kind of set some guidelines for code reviews.
You know, one kind of nice guideline is this idea
that everything has to be reviewed.
I think this is, in general, a good strategy.
I mean, almost everywhere, I think literally
everywhere I've worked at has had this strategy,
you know, that you can't just start making changes.
Now you can
do like an emergency change if let's say it's 2am and you're, you get paged and you have to fix
something right now. But even then, if you do one of these sort of emergency commits, that's not
reviewed, it should send some kind of email so that someone can review it later. I have been at
places which didn't have
this rule and i think the problem is making lots of little change there's sort of a tendency for
people to make a bunch of little changes which they claim are not contentious or don't need review
but then over time they build up into something that really ought to have been reviewed and sort
of flies under the radar because no change was too big. Yeah, that makes sense.
Yeah.
Yeah, I think also in addition to just code reviews, it's good to have these architectural
reviews and things like that.
Those are usually done in person.
Like if you want to propose kind of a new kind of high level feature and things like
that.
Some places have this idea called readability.
And so this is where you get somebody on your team or someone in your department who's really, really good at Python, let's say.
And he's on the code review, but he's not really there to see if your code is doing what you are tasked to do.
He's just there to look at the syntax and look at if you're using the language in the right way and things like that. So there's some companies who have that.
Another thing is, you know, some policies, some companies say, you know, have one person approved.
Some say have two people approved. I generally think one person is fine. I don't really see why
you have to get two people to approve it, but maybe it depends. If some code is really mission critical, then it's good to have, you know,
as you add more pairs of eyes, you're going to catch more and more bugs.
Well, I've seen requiring two people in a way like a kind of more, like a more senior person
working with a more junior person. The more junior person may have more context on that specific
thing, but you may want another sort of senior person to approve the change overall.
But you still want the feedback from the more junior person because they have some contextual awareness or vice versa.
Oh, yeah, that makes sense.
That makes sense.
So basically, some people have more power than other people or a similar way of saying that. Yeah, I think another kind of rule is
you try to keep the code reviews relatively small.
So if, for example,
so one thing that's really important
a lot of people know about is you can often,
when you're using, let's say, Git,
you can do git add dash p,
and it will let you add part of your changes to a commit.
So let's say, for example,
I implemented a new way to get the index of some item,
but then I also took this other part of the code
and made it 10 times faster because I had to
to support the other thing.
Well, those are really two different things.
They might be tied together,
but functionally they're two different functions.
You could have the speedup without having the first thing.
And so that's where something like a git add-p
or the equivalent of whatever source control you're using,
like in Mercurial it's hg-split, is super useful
because you could take part of it and You can make that a code review.
Like, hey, Bob, can you review this speed up?
I ran all the tests.
They all give the same answer, but it's way faster.
Can you look at this?
Are there any mistakes?
And then you could take the other half and you could give that to someone else or give it to Bob, too, but at least as a separate code review, um, that makes
it, it makes it way better to read and, and, uh, makes it way more likely you'll get your reviews
accepted. Yeah. And there's nothing worse than having someone work for like, uh, like a month
or however long, like a long period of time, get a giant code review. And then you have some like,
sort of naming, you know, questions or clarifications or style change and then the person
like the size of the code that they have to go fix when that comment comes in is just preponderous
on top of it's just really daunting to sit down and be like i have to go through many thousands
lines of code for this review it makes it very hard to sit down and do the review yeah exactly
um the other part is uh another thing to mention is,
I think we've talked about this before,
but if you find a bug in a piece of code,
there's an extremely high chance there's another bug in that same code.
It's just, I don't think there's a name for this.
It's some phenomena, but basically, you know,
it's sort of like if you have the wrong mindset that created a bug somewhere,
you created a lot of bugs in that place almost for sure and so by having the code reviews be kind of atomic you know if one code review um is having some problems uh you can really focus on that
and you're not blocking all these other code reviews so yeah that's code reviews in a nutshell. It sounds very kind of Dilbert-esque,
right? It sounds like TPS reports from, you know, office space or whatever. But it's actually,
it's super important. Look at it as sort of a way of communicating, a way of sort of telling
people what you're doing, getting feedback, giving feedback. I've definitely seen,
especially now that they keep coming out
with new versions of C++,
I definitely see things in the code
that I didn't even knew were possible.
And so it's made me a better programmer
and it's highly recommended.
Yeah, I also want to say thank you
to all of our listeners
and all the people who have been sending us feedback,
doing reviews, using our A audible trial or donating on Patreon.
We've been getting an enormous amount of support and we just want to say thank you to all of our listeners.
Yeah, definitely.
Thank you.
And keep writing in.
We try to answer every email and I think we're doing a pretty good job.
We're mostly we had a bit of a backlog.
We're mostly caught up now.
So thank you for all your feedback
and we'll see you next month. Programming Throwdown is distributed under a Creative Commons Attribution Sharealike 2.0 license.
You're free to share, copy, distribute, transmit the work, to remix, adapt the work,
but you must provide attribution to Patrick and I, and sharealike in kind.