Wrap your code

Spend a lot of time with somebody, as many of us are doing in these COVID-19 times and the conversations repeat. Time with any material causes patterns to emerge and familiarity to grow.

When you spend a lot of time with code, the language becomes your own and your fingers can register the next command before your brain needs to process it. Simple pattern recognition and completion. If you've ever gotten several hours into a jig-saw puzzle, you start to load the imagery and shapes into your head so well that just looking at a piece allows you to know where it fits.

But what if you're new to the puzzle?

When you're getting used to the conventions and configurations of an unfamiliar programming language, it may help to wrap some of the code with your own language labeling. 
abrahamKim
 mentioned that he often forgets the syntax for a many-to-many join in the model when writing Laravel code. It's easy enough to look up the proper syntax as he knows exactly what to search for. His browser may already remember where he's going after just a couple of keystrokes. That's not bad. But what if he wrapped that code with something he could remember?

In modern languages, they have what are called first-class functions. It means you can pass the label of a function around as if it were a variable. This allows you to re-label your code by assigning the function label to one more useful / memorable to you.

A wrapper - is a term that means a function wrapper. That is, you take the original code and literally put some code before and after it. This new function is one you understand because you created it. We use this concept all the time in real life when we merge concepts with our own experience and context. For me, the command "make a sandwich" - always has me reaching for Gluten-Free bread. Your context might having you use home-baked loaf; veggies rather than meat. For Amazon logistics, they literally wrap existing products into standardized boxes and labels that make them more efficient to work with. 

To make life and code easier, take existing shapes that are hard to work with and make them your own by wrapping them with something you can more easily handle. If it's a hard to remember function call, wrap it in one that's better named for the way you think about it.
I'm of the opinion that the biggest hurdle to learning code for beginners is the hyperfocus on memorizing things like syntax and functions. Such focus is akin to how mainstream math education is done where they just drill you to death.

I think the better approach is guiding someone in building actual things where you have a steward who helps fill in the gaps so they don't get stuck looking things up and focusing too much on optimization/polish/memorization/wrapping. 


2021-01-26 15:10:14
The hurdle to learning, in general, is an inability to focus long enough to retain the requisite number of concepts. Code is particularly slow because so many layers of abstraction have been layered on -- under the guise of "Making it easier to X"

While it's kinda true, a microwave is much faster to heat up food than starting a fire -- you never seem to appreciate the physics until you've had to keep a fire burning long enough to cook your bacon.
2021-01-26 15:38:22
Yeah so the great way to lower the barrier to learning is to spoon feed beginners just the right amount at the right portion of abstraction at a time.

One time I was focusing on teaching a nine year old how to program stuff in Laravel. At first I thought he might be able to understand controllers and views. But then i realized that that was too much surface area to cover in the first hour. So instead of using a controller I just used a closure in the routes file to put all the logic into that. And I didn't tell him it was a closure. I just told him that's where the function goes. 

From there I switched back and forth between the 'logic' and the 'view'. he seemed to get that.

But in the end, it turned out the more fun part that I would focus on next time was setting up the entire logic infrastructure for him and then helping him come up with creative ideas to tweak that infra. My mistake in this go-round was that I thought that it would be helpful to have him see me write the logic infra but it actually just confused him.
2021-01-26 16:26:54
I think, unless you're getting that direct feedback loop into your brain -- and mapping code to output -- it's going to be hard to grok. Especially trying to translate it through the madeup jargon used by programmers ( not the least of which is Laravel -- Illuminate much? )

If I wanted to put somebody on a path to learning programming, I'd start by helping them understand there's input and output. Keyboard and monitor.

Then, when you get overwhelmed by having it all on the screen -- and not being able to retrieve it -- you might start thinking of data structures, files, etc.

The abstractions come about quite nicely because of necessity - if you give yourself enough time to get bored with the previou abstraction layer.
2021-01-28 04:21:06
I really like this educational method of shifting between levels of abstraction. I was thinking about this in bed this morning. 

Have you started writing any course material yet? I see that you're tweeting titles of what could be courses.
2021-01-28 16:18:02