Talk About Quality

Tom Harris

Archive for the ‘Learning’ Category

Computer Programming – The Rules of the Game

with one comment

A basis of a vector space is a set of vectors in that space that can be used as coordinates for it. [1]

I just read Dan Meyer‘s quick review of the Graspable Math tool. While I did briefly investigate Graspable Math, and also glanced at Desmos, the tool where Dan is head of teaching, what really struck me was how Dan’s writing shows him to be “on the inside” of math teaching and learning. As I am too. That is, there’s a room called “math”, both of us are inside it, and we’re familiar with the rules of the game.

As I love computer programming and am always looking for new ways to teach it, the question arose in my mind: what is the minimal set of constructs to teach students so that they can take off from there and learn the rest of computer programming, in any language, pretty much by themselves?

I did a quick search for “minimal constructs of programming” and found Software Design & Development: Programming Constructs (pdf) from The High School of Dundee in Scotland. Nice and clear, but according to the table of contents, roughly 30 topics. That feels like too many to be minimal.

When faced with the question of how to teach, I usually first turn back to myself – how do I learn? That answer is not likely to be the best or complete answer, because most students are not me. (A valuable lesson for teachers, that I struggle to keep in mind!) But it’s an OK start, and often it’s all I have.

When I learn a new programming language, what constructs do I look for?

  • Variables (scalars, vectors; and assignment – same “=” sign means something very different from math)
  • Operators (may look very different in, say, Python vs APL vs AWK)
  • Conditionals
  • Loops
  • Input/Output
  • Functions (could be an intermediate level topic, but so important for clear code that I put it here)

Maybe also

  • Imports (to get access to additional commands)
  • Classes (for object-oriented programming — question whether that’s an essential or advanced topic)

And there’s also environment and tools:

  • How to edit
  • How to compile (if necessary)
  • How to run (both in editor and from command line — so “command line” is a concept too)
  • How to interact with the program (where do I put input? where do I see output?)

The absolute minimum count of the above is 10 topics. Is that the minimum? Is that the right set? And, is it a set of topics where each one makes sense to a student who is new to computer programming? That last one is so important because (as above), my students are not me.

Thus, towards a second draft of the list, and maybe some hints to what kinds of explanations, exercises, and even learning-support tools (like the math environments mentioned at the beginning of this post, only for computer programming), I want to consider the question in some new ways. Based less on how I learn computer programming, and more on how people, even children, learn things from each other:

If computer programming were an outdoor game played at recess, and I were ten years old, how would I teach my friends the rules of the game?

 

If computer programming were a dance, what would be the basic steps?

What are your answers to these questions?

 

Advertisements

Written by Tom Harris

June 12, 2018 at 12:06 pm

Insights from a Broken Calculator

leave a comment »

Declaring the end from the beginning, and from ancient times things that are not yet done; saying: ‘My counsel shall stand, and all My pleasure will I do’

(Isaiah 46:10)

In elementary school we learned about numbers as if they were only for counting and calculating, skipping right over all the beauty of numbers and their meaning. So I was happy to have this “Calculator Puzzle” brought to my attention via a Twitter post. Not just for the mental exercise, but for the insights it brought about different parts of math (calculation, algebra, and geometry) to name a few, and about how my mind progresses from problem to solution. Definitely not by a straight line. But also not by a random walk.

Spolier Alert:
If you want to try to solve the problems yourself, do NOT read this post, nor my replies on the Twitter thread!

That said, here was my thought process:

Background

calculator is not working properly. Only the add and reciprocal buttons work, as well as the numbers 0-9.

Well that was interesting. Reciprocal is not a key that I often use on a calculator.

Question 1

Can you work out how to halve any number?

I admit, my first reaction, and the one I went with, was to try a specific example first. And, as above in Isaiah, to “declare the end from the beginning”.

Say, half of 5. That would be 5/2.

How could I get from “5” and “half” to 5/2, with only “+” and “1/x”?

Impressed by the unusual button — reciprocal — I immediately asked: could I get 2/5?

Well, yes. 1/5 + 1/5 is 2/5.

That was it: 5, 1/x, +, 5, 1/x, = would give 2/5. Another press on 1/x would give 5/2. Q.E.D.

Insight 1a*

Better than solving the problem, though, is that as an electrical engineer, I felt a sense of “coming home”. I hadn’t seen it at first, but this was “reciprocal of the sum of the reciprocals”. Well known as the resistance of a set of resistors in parallel. So it would certainly work for every case, because two equal resistors is two equal paths instead of one, offering half the resistance. Whether you feel that math or electricity is the original depends on whether you’re a mathematician or an engineer.

* Where’s 1b?? You’ll have to wait for that. I did.

Question 2

Now the subtract button has started working.

I think this means I can now square any number – can you work out how?

Here, I rushed ahead too quickly to generalize. I offered a solution where squaring is a special case of multiplication. The original questioner gently encouraged me to try again without repeated addition.

Back to my specific example. 5. 5 squared is 25. No way I would get directly to 25, but now that I was friends with that reciprocal button, I sought 1/25.

After a few minutes of that, I realized that I would have to use the “-” button. Surely it was working (in the problem) for a reason.

1/25 is pretty small. I would get it by subtracting fractions (which I could generate with the 1/x button). But I couldn’t think of any fractions to subtract, certainly not with a numerator of 1, that would yield 1/25. I did realize that fractions with denominators close to each other would yield significantly smaller fractions. How about 1/4 – 1/5 = 1/20. OK, 1/20 was not 1/25, but maybe I could fix it up. 1/20 would yield 20 (after pressing 1/x). Then simple enough to add 5 and get to 25.

5 squared = 5 + 1 / (1/4 – 1/5).

I generalized: n^2 = n + 1 / (1/(n-1) – 1/n)

Why would it work in general? Algebra:

n + 1 / ( (n – (n-1)) / (n(n-1))) = n + 1 / 1 / (n(n-1)) = n + n(n-1) = n + n^2 – n = n^2.

Q.E.D. again.

Insight 2

Why is 1/4 – 1/5 = 1/20? What’s special there? Suddenly, though I had never seen it written down, I thought: “Consecutive integers are relatively prime.” Then I looked that up to be sure. I read some proof discussions, and then left off that to continue the problem.

Question 3

Now, I think I can also calculate the product of any number. How?

Here, I was onto the power of algebra to solve problems “automatically”. Instead of one number n, I would have two numbers x and y. I asked myself what product expressions involving x and y I was familiar with. The product (x+y)(x-y) came to mind. In high school it always seemed nice because it produced a sum of squares “cleanly” with no annoying middle term in xy. But here, I realized, “xy” was just what I was looking for. So the product would be the “messier” one: (x+y)(x+y). Which, by the way, is (x+y)^2. Aha! Is this is why the problem author tried to take me by the hand from square to product?

Anyway, (x+y)(x+y) = x^2 + 2xy + y^2. That could be solved for xy:

xy = ((x+y)(x+y)-(x^2 + y^2))/2.

Insight 3

I like geometrical interpretations more than, or at least in addition to, purely algebraic interpretations. Even if algebra works, I feel better seeing a picture too. So I went back and asked myself what picture matched that equation. Here it is (freehand drawing):

product

Insight 1b

Now, even though I had solved question 1 without any algebraic symbols, I challenged myself to find a geometric interpretation for the reciprocal of the sum of the reciprocals, with two equal numbers yielding a half.

One geometric interpretation of reciprocal is the (negative of the) slope of the perpendicular. With that in mind, the picture came pretty quickly:

reciprocalsumreciprocal

Question 4

Are there any other operations I can do with only add, subtract and reciprocal?

I left this for when I find more time. Or maybe a reader would like to offer some thoughts? Not just the “answers”, but your thought process, and any insights that come up for you!

 

 

 

 

Written by Tom Harris

March 5, 2017 at 5:16 pm

Posted in Learning, Math

Learning a New Programming Language, with Life (part 4)

leave a comment »

While preparing a course syllabus on coding in Python, for an upcoming high school class, I remembered static analysis. I haven’t decided how soon to introduce the topic, but I thought I’d better check how my own sample program fared.

No warnings or errors from Python itself. (If there had been I would have addressed them already!).

So I installed Pylint and tried its default settings. How about that. Not zero at all!

In fact, 54 coding convention messages, 12 warnings, and 1 recommendation for refactoring.

It was easy enough to clean up whitespace issues (helped to turn on “view whitespace” in my Notepad2).

And yes, many comment lines were too long. I left-justified (but indented for Python) for easy reading.

Some of the warnings are for my “TODO” comments — an extra reminder to do, or drop, next steps I’d identified earlier. Pylint message count is now down to 2 informational messages, 28 coding convention, 13 warnings, and 1 to refactor. They are valuable for my future Python learning (and teaching):

Locally disabling unused-variable (W0612) (locally-disabled)

I disabled those warnings because I know the code needs those variables. But I’ll have to explain why.

(Pylint doesn’t forget — the 2 new informational messages remind that I’ve suppressed two warnings.)

Invalid attribute name “maxRowMain” (invalid-name)

Not just that name. Most of my object names. I’ll have to find a good object-naming convention and use it.

R: 69, 4: Too many branches (13/12) (too-many-branches)

Just today I heard a Python lecturer on YouTube say, “if you’re not refactoring, you’re not learning.” Yes, that function is the longest. Not so complex, but could be simpler and easier to understand.

Attribute ‘maxRowMain’ defined outside __init__ (attribute-defined-outside-init)

A few of those also. I will have to go back and learn again about __init__: when to use it and why.

All in all, a good learning session, and direction on what I need to learn next.

Thanks to static analysis with Pylint.

Written by Tom Harris

September 2, 2015 at 10:30 pm

No Free Lunch

leave a comment »

Recently I read an article by Norman Balabanian (“On the Presumed Neutrality of Technology”, IEEE Technology & Society magazine, reprinted Winter 2006, pp. 15-25; originally published in 1980), where he addresses, among other things, the popular claim that people choose new technologies out of free choice. That if we use a technology, whether it be a car, or a refrigerator, or permanent-press clothing, we freely choose the benefits, and have accepted the costs. In several examples, Balabanian shows that we do not. We live modern life as part of an interlocking, consumption/profit-driven system which requires us to accept most of the new technologies, or starve.

I decided to do a small experiment in the household, to see up close what Balabanian was talking about.

The Experiment

I set out to collect and put aside all the food packaging that our family opened and threw away as part of our meals at home for one week. Not paper plates or napkins, or non-food trash such as newspapers. Just the containers that our food comes in. My kids wondered at first, but after a day or two I convinced them that even after school people still learn, and this was my self-assigned science project this week. As material rapidly piled up, I cut off “data” collection at 4 days.

What did I find?

I collected a half-full garbage bag of paper and cardboard, similar of plastic bags and bottles, and a few metal cans, for a total of 1 kg of waste material. By weight, the packaging was a bit less than 4% of the food net weight. Not much at all, but I was not concentrating on waste vs. recycling.

Rather, I was looking at the question: have we freely chosen to buy our food packaged?

Looking at the list below, I have to say “no”. Very few of these foods are available for purchase either at our corner grocery, or our large supermarket, without the packaging (i.e. take in your own container).

Reminds me of a cynical saying we used to have in high school: “You have a choice … and it has been made for you.”

The Challenge to Innovators

Don’t tell me how to recycle these materials. (We do already—as much as our city provides for.) That’s more forced choice: take the food in packages, and then recycle the packages.

Instead, suggest ways that we or the food distribution system could change so that we could eat our (reasonably) healthy diet without all the packaging in the first place.

Appendix 1: Four Days of Food Packaging

Food Amount (g) Type Wrapper Type Comments

Cheetos™ 55 Prepared Plastic Silverized
Pudding 330 Prepared Plastic
Fruit 1000 Prepared Plastic Styrofoam
Flour 2000 Prepared Paper
Cola 3000 Prepared Plastic
Milk 3000 Raw Plastic
Cereal 1200 Prepared Paper Waxed cardboard
Cereal 0 Prepared Plastic
Cottage Ch. 250 Prepared Plastic
Sugar 1000 Raw Paper
Potato Chips 50 Prepared Plastic Silverized
Eggs 1400 Raw Paper Cardboard
Soda Water 1500 Prepared Plastic
Smoked Salmon 100 Prepared Plastic
Granola 500 Prepared Plastic
Brown Sugar1000 Raw Paper
Yogurt 450 Prepared Plastic
Fruit Juice3000 Prepared Plastic
Margarine 2000 Raw Paper Waxed paper
Tuna Fish 320 Prepared Metal
Pineapple 825 Prepared Metal
Crackers 325 Prepared Plastic Silverized
Egglplant Spread 1000 Prepared Plastic
Mineral water 3000 Raw Plastic
Total Food Weight 27305

Written by Tom Harris

April 23, 2007 at 6:31 pm

Necessity is the Mother of Learning

leave a comment »

I may be an exception, but if there’s one thing I enjoy, it’s buying the right tool for a specific job, when the job needs doing. It gives me an excuse to buy a new toy, as well as the pleasure of having a task go smoothly. Faithful readers may remember my first post here, Choose and Use the Right Tools, where I didn’t, and how that turned out.

Today I got a second chance, when my son decided to move his PC to the other side of his desk. With my wife’s permission, we set out to drill another hole for the computer cables. (My wife designed the desk, which is probably worth a good deal more than the PC.)

This time, when I got home from work, I was already presented with a new special-purpose hole saw. There was a little concern that it cost $20, but I reassured everyone that it was fine—this time we would use the right tool and get the job done nicely.

We got all prepared: cleared the work area, measured and marked the hole center on the bottom of the desk to ensure clearing the frame of the desk, put masking tape on top to prevent chipping, and drilled a starter hole all the way through. Came to putting the hole saw in the drill, though, and … it wouldn’t fit.

My son sped up—started thinking of all sorts of quick ways to attach it to the drill anyway.

I slowed down. I decided I would either become much more knowledgeable about hole saws in 15 minutes, or we would put the whole thing away ’til tomorrow and ask at the store. Well, I learned about what a hole saw and drill look like together, what mandrels are and what arbors look like, and finally settled on the understanding that my drill should definitely accept bits with up to a 1/2″ diameter shank. Pretty technical, huh!

All I can say is that this newfound knowledge gave me the confidence to open the drill chuck a bit larger, and then the hole saw (1 cm metric shank—do the math) did fit. We continued the job, including drilling the hole half of the way from the top, and the other half of the way from the bottom, so that the finishing cut would be in the middle of the desk thickness where it wouldn’t damage either surface. Out popped a plug of wood, just like in the picture.

What, you might wonder, does all this have to do with learning, and software development?

For years I’ve been trying to learn about regular expressions because they seemed so useful. But I never got very far until this week. I had to prepare a demonstration of integrating a source code editor (my current favorite—Source Insight) with some XML-modified output from PC-Lint. Well, it took me more than a hole saw’s 15 minutes, but a lot less than “years”. About an hour-and-a-half and I had—rather suddenly, it seemed—taken control of regular expressions for myself.

What made the difference? I had a specific task to do. I was no longer focused on the learning, but, as with the hole saw, on the necessity of the task at hand. A real task, whose result I had promised to someone else. With that promise, the learning just came by itself.

Written by Tom Harris

November 9, 2006 at 1:38 am

Posted in Learning

Tagged with

Learning for Standards Compliance

leave a comment »

Standards compliance is the unsung hero of modern product usability. It’s how every appliance plugs into any outlet in your house. How gas from any gas station works in your car. There are even standards for the size of the spout so that you don’t put diesel in your gasoline-powered car.

So it comes as no surprise that where that most popular consumer appliance, the car, meets the most modern one, the computer, someone has made a big effort to define a standard. Specifically, the (British) Motor Industry Software Reliability Association has set as its mission, “To provide assistance to the automotive industry in the application and creation within vehicle systems of safe and reliable software.”

But what does that mean to the individual software developer?

Your company buys the standard (it’s becoming popular with many embedded software manufacturers, well beyond the car industry). Developers read it. Maybe there are a few lectures on the benefits and the details. But is that enough?

Fast-forward to a typical work day …

Scenario
 
Developer is in the middle of coding for an urgent delivery or bug-fix, and is confronted with a compiler warning, Lint-type warning, item in a coding standard, or code review comment. (If the company has done its deployment job well, all of these different types of warnings will ultimately be connected to the coding standard.)

What’s really going on for the developer
 
The developer has to understand the warning, standards item, or comment, and then decide:

  1. How to change the code to comply, while not breaking anything else
  2. When to make the change, in order to meet the deadline for the rest of the features/fixes in the delivery

The coding standard is no help for either of these decisions.

Both decisions are context-sensitive, and require guidance (or mentoring — call it what you want) to decide correctly.
 
Implication
 
For the producer, standards compliance includes a learning effort. And in software development, that learning effort can be significant and ongoing. The learning program must not only provide the understanding, but also the people to accompany developers as they confront these two decisions over and over.
 
The first step is participants’ acknowledging this reality. Second is identifying the mentors and allocating their time to read code and provide guidance. Then you can plan a learning program for code quality improvement through standards compliance— a program that works.

Written by Tom Harris

October 15, 2006 at 1:51 pm

Posted in Learning

Tagged with , ,

Mentoring is Kids’ Stuff

with one comment

Here’s Ron Porter commenting on that 30-to-1 ratio of productivity we hear about. He talks about the top performers bringing the others up to speed. That’s not a way things work — it’s the only way.

In high school I was always on the “B” team in soccer. (Back then I was a 5 out of 30 at soccer.) My best days were when they mixed us with the “A” team — our defense with their forwards and goalie vs. their defense with our offense and goalie. Playing defense with an “A” team around me made me play better.

There are two reasons to try to make the “A” team; together they offer an opportunity for everyone. Either you are really good so you get on the “A” team, or you want to be good so you need to get on the (bottom of the) “A” team so you’ll improve.

Then Daniel Read asked how Ron mentored welders. (That’s what Ron was doing before he was programming, and perhaps before he started building boats.) Ron gave a 3-step program:

1. Stand up to superiors
2. Be willing to suffer ridicule
3. Keep records of everything

That’s my paraphrase — read how he said it: How to mentor a welder.

Ron, you’ve got it exactly right. I can assure you that it is “directly transferable to … other kinds of jobs.” Certainly not just programming. I sometimes think that programming (now called “software development”) is the only profession that thinks it’s so, so different. Yes software is different, but people in it are not.

About whether mentoring works like this everywhere: of course it does. It’s simply called “how people learn”. I wrote about it here. But don’t read me. Read Ivan Illich’s Deschooling Society.

When I’m not reading or working, I’m learning to roller blade. A pair of skates, a video here, a website there, and some practice. Gets me to about 1 out of 30. Apply Ron’s rule #2 though, and I go out to the park where all those kids skate circles around me. They’re all 10-out-of-30 going on 20-out-of-30 skill-wise. I watch them and even ask them questions. They’re fascinated for a moment that an adult might ask a kid how to do something. But they get over it quickly — acting like natural mentors. Which they are. And how about that — now I can actually skate around the neighborhood.

Mentoring is no mystery. It is kids’ stuff.

Written by Tom Harris

July 21, 2006 at 12:17 am

Posted in Learning

Tagged with ,