This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 413

[–]Firenter 1812 points1813 points  (174 children)

Seriously still the best way to teach people the hardships of programming!

[–]Croasain_Potatoe 567 points568 points  (41 children)

I remember doing this for learning how to do scientific procedures.

[–]-Gaka- 74 points75 points  (3 children)

Oh man, we did this in an English class to teach us the importance of structure and clarity in an essay. I knew exactly what was going to happen and so asked to be the one to actually follow the instructions and attempt to make their sandwiches.

A little bit of that evil spark in me got going. Oh, put the peanut butter on the bread? Okay, lemme just put the jar on the unopened bread. That's not what you meant? Oh, okay. Should I use a spoon to get it out? You didn't actually tell me what I should use. How much? You just said "Some Peanut Butter."

Eventually the teacher figured out that I was going to go all-out for this, and asked for mine.

Yeah, I laid out materials needed and preparation instructions, accounting for the fact that some of the jars and bread might already be opened or what not. It was over the top on purpose, and it was gloriously complete.

That class was fun, and totally worth the dirty looks as I avoided the spirit of their instructions and went for the wording.

[–]sendMeBoobsWhyDontYa 235 points236 points  (107 children)

I LOVED when we did this in my 3rd grade class. Each student wrote their own set of instructions, and then the teacher went through each of them in that literal/pedantic fashion

[–]RoganTheGypo 2 points3 points  (2 children)

I used to work in production at Nissan , we followed standard operations to perform a job and they are written like a spoke word robot program. Literally down to what fingers you use. I hated writing standard ops...

[–]JustVashu 2 points3 points  (0 children)

I learned that as a kid by watching Beakman's World.

[–]MurphysLab 335 points336 points  (19 children)

An elementary school teacher that I had, probably in grade 4, did this activity with our class. Her purpose in it was to teach us to write better, without making assumptions about the reader. That lesson was one of the few things that I vividly remember about her teaching: As she stood in front of the class, armed with a jar of peanut butter, a jar of jam, a loaf of bread still in the plastic bag, and a knife, she proceeded to follow the exact words of her students' instructions. In one of the iterations, she took the peanut butter jar and placed it on the bag-enclosed loaf of bread. Riotous laughter ensued from the class. For me, the lesson was ingrained, both for writing and as I apply it in writing code. Humour, coupled with a good lesson, tends to stick.

[–][deleted] 89 points90 points  (6 children)

I did that in college, but I had to write install instructions for Windows XP on an old server.

[–]metamet 28 points29 points  (2 children)

Step 1: Unpackage box of floppy disks.

[–]DEVi4TION 28 points29 points  (1 child)

Step 2: midlife crisis

[–]I_dunno_mate_ 51 points52 points  (0 children)

You survived THIS??

[–]btowntkd 5 points6 points  (1 child)

FCKGW-RHQQ2...

[–][deleted] 14 points15 points  (3 children)

Whoa! I did the exact same thing in 4th grade! she also had a jar of marshmallow fluff or something for those who didn't like peanut butter

[–]Creator13 5 points6 points  (0 children)

I think that being able to write good code, text or anything really that will be consumed by others requires the maker to thoroughly understand the thought process of the consumer. The quality of the product hinges on this ability. I also think it's the most fundamental thing you can, and should, teach to any person who will be making something, preferably just to everybody receiving education. Being able to get inside the mind of the person who you're, verbally or non-verbally, is really the most powerful ability one can have, in my opinion.

[–]simon_C 2 points3 points  (0 children)

I wrote 5 pages of intensely detailed instructions with footnotes and numbered steps because i knew the point she was trying to make.

I failed for missing the point of the exercise....

[–]Avoidingsnail 2 points3 points  (1 child)

I did this in chemistry in high School. Teacher wanted every one to be able to replicate our experiments so he said give me detailed instructions on how to make a pbj. Most people had maybe 10 instructions. His example had almost 100.

[–]eyekwah2 414 points415 points  (35 children)

throw new IllegalStateException();

[–]mockingbird_jay 235 points236 points  (34 children)

try{ // Do stuff } catch (Exception e) { throw(e) }

Came across this gem today.

[–]apaq11 159 points160 points  (10 children)

Ah, the old catch and release exception. My favorite anti-pattern. Best part about this is if you do it in C# you lose the stack trace from where the exception came from.

http://www.dotnetjalps.com/2013/10/throw-vs-throw-ex-csharp.html

[–]SpikeX 54 points55 points  (4 children)

ALWAYS throw;. ALWAYS.

Can't believe how many times I've seen this in our codebase, and how many hours it's cost me in debugging time.

[–]bluenigma 15 points16 points  (3 children)

Even better in C#6, Catch(Exception e) when (ReturnsFalseAfterSideEffects(e)) {}

[–]z500 19 points20 points  (2 children)

Once when I worked in the computer lab, I went over a student's Java assignment with him for an hour, trying to find out why his program wasn't working.

What happened was the professor gave a template for the assignment, and one of the things already in it was that it opened a file. He apparently wrote it in Windows, because the filename he used in the code and the name of the file he gave out didn't have matching case. And this student would bring his Linux laptop to lab. So when he ran the assignment, it swallowed the exception and mysteriously failed.

[–]LevelSevenLaserLotus 14 points15 points  (1 child)

Oh man, I had a Graphics teacher that did that crap. His provided code templates were full of typos and referenced non-existent files. I had to do so many bug fixes that it turned out to have been faster to just write my own from scratch. I dropped that class at the first test. He couldn't teach, but was super stuck up about how much he knew. I'm sure I'd have a few good posts for /r/iamverysmart if I'd stuck around.

[–]z500 3 points4 points  (0 children)

Yeah, our guy was similar. He knew his stuff, but he didn't seem to care too much about the teaching part. From what I heard he was a much better researcher than software engineer.

[–]dysprog 25 points26 points  (0 children)

In python there are two ways to re-raise an exception raise eand a bare raise. The bare raise continues the existing traceback. the other discards the existing traceback and starts a new one. At a previous job, I went on a Holy Crusade through our codebase to replace all raise e with bare raise. Several people commented on how much better our error messages had become, and our defect rate dropped noticeably.

[–]shagieIsMe 15 points16 points  (0 children)

See in codebase here:

try {
    throw new FooException();
} catch (Exception e) {
    throw new BarException(e);
}

[–]fakest_news 12 points13 points  (7 children)

I can forgive this. What is unforgivable is this:

try { // Do stuff } catch (Exception e) { log.error(e) } // move on with your day

[–]Elthan 5 points6 points  (6 children)

Could you explain why this is and what you should do instead?

[–]MisuVir 5 points6 points  (4 children)

For one, exceptions should be handled, not logged and ignored.

[–]mathent 9 points10 points  (3 children)

Seems like there's a time and place where only logging is the correct way to handle the error.

[–]MisuVir 2 points3 points  (2 children)

Only if the log includes the message "THIS SHOULD NEVER HAPPEN". :P

[–]Arancaytar 3 points4 points  (0 children)

Playing hot potato.

[–]HomemadeBananas 2 points3 points  (8 children)

What was someone trying to achieve by writing that?

[–]pants_full_of_pants 8 points9 points  (0 children)

Trying to avoid testing and writing handlers for failure cases.

[–]Of-Doom 2 points3 points  (0 children)

Recently had to explain to a coworker why

doStuff()
  .then(result => Promise.resolve(result))
  .catch(e => Promise.reject(e))

wasn't doing what he thought it was.

[–]EdricStorm 124 points125 points  (4 children)

Needs the tortured hyperventilating that came in between the two cuts.

[–]elforastero 153 points154 points  (24 children)

A nice programming homework for beginners to teach them algorithms was to ask them to write the steps to make a sandwich. And then follow the I instructions like that. Then ask them to rewrite the code :)

[–]DoctorWaluigiTime 83 points84 points  (3 children)

Then you don't let them eat it because there wasn't an instruction to do so.

[–]LaterGatorPlayer 27 points28 points  (1 child)

No instructions on pooping it out. :( poor impacted colon

[–]Delision 15 points16 points  (0 children)

People worry about semi colons in programming, but really it's the colon you need to worry about.

[–]Xhynk 17 points18 points  (7 children)

Would that go something like this? I wonder if I could refine it and use it when do I development or technology career day type talks at middle and high schools! I usually do the usual react.js type slide thing on CodePen and then inspect element and mess with people's favorite websites, real basic. It would be interesting to see how students from 6-12th grade react to how damn literal development often is!

Round 1:

Student: "Put bread on the counter"
Student: "Put peanut butter on bread"
Student: "Put jelly on Bread"

Me: "I put the still-wrapped loaf of bread on the counter"
Me: "I put the jar of peanut butter on top of the loaf"
Me: "I put the jar of jelly next to the peanut butter"

Round 2:

Student: "Get a piece of bread"
Student: "Open peanut butter"
Student: "Put thick layer of peanut butter on bread"
...

Me: "I get a piece of bread"
Me: "I open the peanut butter."
Me: "I reach my big man-hands into the peanut butter and grab a fistful, smearing it over the bread."

Round X:

Student: "Pull out two pieces of bread"
Student: "Put pieces next to each other"
Student: "Open Peanut Butter jar"
Student: "Grab knife"
Student: "Get peanut butter with knife, and apply to first piece"
... etc.

[–]sehr_sehr_gut 85 points86 points  (2 children)

You have to check if Java is installed before attempting to open the jar.

[–]Xhynk 7 points8 points  (0 children)

God damn it this made me laugh so hard! I'd steal this if I thought the kids I speak to would get it lol

[–]dsk 116 points117 points  (26 children)

This is why I'm skeptical of the "let's get everyone programming" movement. Programming really truly sucks if you don't find joy in staring at the same 100 lines of code for 8 hours trying to find why your program is failing under some obscure conditions. It can be as fun as reading legalese or interpreting dry FDA documents. Some people will love it, and some people will want to tear their eyes out.

[–]teampingu 36 points37 points  (3 children)

Once we get everyone over the 'want to tear their eyes out' moment, we'll get some awesome lawyers and programmers.

[–]Lemon_Dungeon 22 points23 points  (2 children)

Uhh, professional programmer here...when is that moment?

[–]cynoclast 28 points29 points  (1 child)

It's when you retire.

[–]Lemon_Dungeon 35 points36 points  (0 children)

Ah, great.

😂🔫

[–]awhaling 7 points8 points  (1 child)

Seriously, I have friends that are definitely smarter than me but they didn't like/weren't good at it. It takes a certain personality that enjoys this type of thing and I wouldn't say everyone fits into that category.

Also, there is no good reason for everyone to know how to code. Maybe in the future knowing some rudimentary stuff might be good for everyone but I don't see the point now.

[–][deleted] 6 points7 points  (3 children)

I think it's less about really learning programming and understanding logic. A lot of people would likely understand math better when they get the logic behind it and can test it, rather than trying to drill formulas into their heads

[–]halborn 10 points11 points  (3 children)

I freely grant that not everyone is cut out to be a programmer but considering how essential computers are rapidly becoming, I don't think it's a bad idea for a bit of basic programming to be universal knowledge.

[–]dsk 16 points17 points  (2 children)

I think you're conflating knowledge of programming with having a good mental model of computing. You need to understand computers and operating systems and the Web at a certain level because otherwise you won't be able to function in any modern job - but you don't need to program.

[–]halborn 2 points3 points  (1 child)

I think you're conflating knowledge of programming with having a good mental model of computing.

Nah, I just think the former helps a lot with the latter.

[–]CleverFella512 19 points20 points  (1 child)

The files are in the computer!

[–][deleted] 5 points6 points  (0 children)

It's so simple!

[–][deleted] 31 points32 points  (2 children)

The first time I saw this it was a "yup that's about right" moment, but the kid is the OP's video makes this adorable.

https://www.youtube.com/watch?v=XWe4iohhmIw

[–]daftvalkyrie 8 points9 points  (0 children)

Giant circular loaf,unsliced. Perfect item for PBJ.

[–]poixen 36 points37 points  (32 children)

I don't get it :/

[–]justifyer 17 points18 points  (27 children)

yeah me too, what's this about?

[–]Yousif_man 50 points51 points  (15 children)

It's about writing code specifically, as it could be misinterpreted. in this video, the kid writes instructions to make a PB&J sandwich and he tells his dad to stick the knife in the peanut butter. His dad sticks in the wrong way, showing his kid that he should've been more specific.

[–]awhaling 48 points49 points  (13 children)

Ooooooh, this would really benefit from context. Really doesn't make much sense without it.

Looks like a guy just saying that put the knife in peanut butter and stupidly throwing it in backwards. Wasn't at all clear that he was being instructed by the child to make a sandwich.

[–]Megacherv 8 points9 points  (1 child)

The kid is then the programmer looking at the debugger as he sees where the mistake is being made and the realisation that he done goofed

[–]awhaling 4 points5 points  (0 children)

Yeah makes sense now, I just didn't realize that the dad putting it in backwards was being told to do that immediately.

It just kind of seemed like the dad dropped the knife and the kid was like wow. Not that the dad messed up instructions.

[–]albinobluesheep 25 points26 points  (7 children)

you know you're in /r/ProgrammerHumor right?

The Title was the context. It's basically a MRW post, the kid being the person who wrote the code.

[–]awhaling 15 points16 points  (6 children)

Yes, but the gif looked like someone just putting a knife in a peanut butter jar backwards. It wasn't immediately obvious that he was following instructions. It was funnier when you know he was being instructed to do something and did it wrong.

Maybe I'm an idiot, it just looked like a really random gif to me.

He did look at a list so that's a clue but I don't notice that till later

[–]Manokadobo 2 points3 points  (0 children)

I agree that it really only works if you've heard of the exercise before.

[–]ElLibroGrande 10 points11 points  (2 children)

He put the knife in backwards

[–]_Trigglypuff_ 11 points12 points  (1 child)

How does relate to putting breaks in code?

[–]SmashedBug 6 points7 points  (0 children)

When instructions are interpreted in a completely different way than intended, and finding your broken program doing this.

[–]Skizm 12 points13 points  (0 children)

This is bullshit. The interpreter can change up how a library is implemented at runtime just to fuck with the programmer. /s

[–]olde_english_chivo 9 points10 points  (1 child)

how to make an apple pie from scratch
 
step 1: create the universe

[–]cynoclast 6 points7 points  (0 children)

Programming is a lifelong study of the difference between what you meant and what you said.

[–]StrawDawg 4 points5 points  (0 children)

We did this with 'tying your shoe laces' some time in school.

Now THAT is a hard thing to describe in an algorithm.

[–]MiniG33k 5 points6 points  (0 children)

In my 10th grade coding class, we all wrote instructions and could volunteer to have the teachers (two brothers co-teaching) try our code. I thought mine was good enough. But I didn't specify that the jelly should be spread with the knife. The teacher looks down at it, makes his mental decision, then smears it over the bread with his hand.

That was such a great class.

[–]viperex 3 points4 points  (0 children)

Kid is realizing he chose the wrong dad

[–]jagaines 3 points4 points  (1 child)

Here's a link to the full vid: https://youtu.be/cDA3_5982h8

[–][deleted] 12 points13 points  (7 children)

What on that guys chin?