doug — off the record

just a place to share some thoughts


Writing and Sharing Code

A while back, I had made reference somehow/somewhere to this infographic.

Thanks, mint.com.

It’s an infographic that claims to show how a credit card number can be validated.  I don’t know if the algorithm explained is true in all cases but it was interesting.

It’s kind of interesting when you have people reference your resources.  It’s an indication that someone is actually reading the resources and blogs that I’m creating.  So, it was with a smile that I read a message from Alfred Thompson (@alfredtwo) on Twitter) asking if I remembered the infographic about credit cards verification.  A quick search and I was able to send him the link.

I also sent Alfred a smart aleck comment to the effect "I smell a Computer Science problem here".  Alfred, if you don’t know, is the K-12 Computer Science Academic Relations Manager for Microsoft.  Within minutes, he got back to me indicating that that was exactly what he was up to.

As I look at the algorithm, it is indeed something that’s easily handled in secondary school Computer Science.  You need to ask the user to enter a credit card – it sure can’t be an integer with its 16 digits – then rip it apart digit by digit – do a little mathematical calculation – and then finally validate the check digit to make sure that the number was valid.

I had to go out and do something right after the exchange with Alfred and when I got home, I thought "What the heck – I’ll whip up the code to solve this".  In my Computer Science teachable qualification course at the university, we’ve talked about how teachers should solve all of the problems that they give to students so that they know, in advance, the challenges that students will have.  We had also talked about choice of languages and one of the ones that we had played around with (and enjoyed) was Microsoft’s Small Basic.  Now, we had done some silly little programs in class but this was a little more involved and so I decided to code the solution with this language to see how it looked.

It took probably 20-30 minutes as I had to learn some of the nuances of the language in order to make it work.  Eventually, it was done and I thought that I would share it with Alfred.  Now, in a traditional world, I’d save the code to a text file and then email it to him.  Given my blog post of yesterday, that would be a little hypocritical.  However, as I noted in the post, there are better ways to share resources and Small Basic fills the bill there.  Instead of saving the application, I just publish it.  The code goes off to Microsoft’s cloud and I’m given a code.  Could it be this easy to share?

Ever the skeptic, I save the program locally, shut down Small Basic and reload it.  This time, I give it the code I received before and, voila, there’s my program.  Sweet.  The code is on the way to Alfred.  Perhaps I could save him a little time but I suspect that he’ll write his own program and do a better job at it. 

From this experience though, I had a number of things confirmed.  The best programs for the classroom solution are all around us.  We just have to find them.  I’m impressed with how Small Basic could handle it.  I’m even more impressed with how easily I could share my code.  In the classroom, what a great way for students to collaborate. Or, from a teaching perspective, I could distribute a program for students to debug, or to distribute the basics of a program and allow them to complete it.  Best of all, Small Basic is free and so the home/school connection gets stronger.

I love it.

Powered by Qumana



3 responses to “Writing and Sharing Code”

  1. There’s a similar algorithm with Canadian Social Security numbers, but I don’t remember what it is. I know that my mother (who works with SS#’s) can glance at one and tell you if it’s a real one or not.

    Like

  2. […] Or just try it as embedded below. Doug writes about how his example and my blog post came about at Writing and Sharing Code BTW. And he is right that I should write up a solution myself and it is on my todo […]

    Like

  3. […] Or just try it as embedded below. Doug writes about how his example and my blog post came about at Writing and Sharing Code BTW. And he is right that I should write up a solution myself and it is on my todo […]

    Like

Please share your thoughts here. I’d enjoy reading them.

This site uses Akismet to reduce spam. Learn how your comment data is processed.