laurathepluralized

joined 2 years ago
[–] laurathepluralized@lemmy.world 2 points 2 weeks ago* (last edited 2 weeks ago)

This is a great analogy! To build on these points and the analogy: I like to think of my coding in terms of inputs, outputs, and what needs to happen to the inputs to get the outputs I want: that is, inputs->how->outputs. So for this buttered toast analogy, your inputs would be:

  • toaster
  • electricity
  • bread
  • butter
  • knife
  • plate
  • operator's hands

The desired output: toasted bread on the plate with butter spread on one side.

The "how" is the sequence of specific instructions the instructor gives to the operator.

This approach is even more helpful as you start working on larger projects; as you think about a problem you're trying to solve, try to break the overall input->how->output into smaller modules of input->how->output, and then you can use those modules (often called "functions" or "methods") in the overall "how." Let's say you want the instructor and operator to prepare a full breakfast with bacon, eggs, and buttered toast. You'll have some more inputs, of course (frying pan, raw bacon, shelled eggs, stove, in addition to the toast components), but since you already made a known-good make_buttered_toast function, you can incorporate that function into the pipeline to go from your more comprehensive set of inputs to the full breakfast outputs, and you can make separate functions for making the bacon and making the eggs. Finally, your overall program can then call your bacon, eggs, and toast functions to result in the desired output of a full breakfast.

Now here's where breaking the problem down into smaller input->how->output chunks really comes in handy: one day, you are tweaking your breakfast-making code, and suddenly, your overall outputs have good bacon and good toast, but the eggs wind up dumped half-cooked on the stove. But since you made nice, modularized functions for toast, bacon, and eggs, you automatically know more where to start looking for the bug: the eggs function.

There's a lot of good advice in the responses to this post! Overall, I just wanted to emphasize what I wish I had learned much earlier on in my career: the benefits of thinking in terms of inputs->how->outputs and modularizing sub-problems in the overall program's "how" into subproblems that can be independently considered, debugged, and re-used on future projects. (A secret for you: those of us who have been coding for a while often don't start everything from scratch--we'll re-use some functions or classes we wrote in the past, tweaking them as necessary for new applications, but not needing to start from a blank text editor :) ) Learning to write applications in code is exploring a new way of thinking about problems and how to solve them, and personally, I find it very rewarding!

I wish you all the best on your coding journey!

[–] laurathepluralized@lemmy.world 2 points 4 weeks ago (1 children)

Yes! Another fan of spicy sausage in stuffing! My mom one year made the stuffing (not cornbread-based--Stove Top brand with savory herbs, I think) with half mild sausage and half spicy sausage for younger me who didn't like much spice. We also added pecans and dried cranberries in addition to onion and celery. We've barely ever deviated from that recipe since!

Even better: purchase an inexpensive strap wrench with a rubber strap (something like this) and keep it in the kitchen for stubborn jar lids. For the jar lids that even a strap wrench alone can't quite open, I've had success by using the strap wrench on the lid while holding the jar itself with a silicone oven mitt (or oven mitt with rubberized grip--the rubber band trick might work here as well).