# Writing and Sharing Code

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.

The content of this blog is generated by whatever strikes my fancy at any given point. It might be computers, weather, political, or something else in nature. I experiment and comment a lot on things so don't take anything here too seriously; I might change my mind a day later but what you read is my thought and opinion at the time I wrote it! My formal education includes a Bachelor of Mathematics degree from the University of Waterloo and a Bachelor of Education degree from the University of Toronto. Ontario Ministry of Education and Training qualifications are in Data Processing, Computer Science, Accounting, and Mathematics. My personal website is at: http://www.dougpeterson.ca Follow me on Twitter: http://www.twitter.com/dougpete I'm bookmarking things at: http://www.delicious.com/dougpete

###### 3 comments on “Writing and Sharing Code”
1. Colin Jagoe says:

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.

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 [...]

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 [...]

#ECOO14
Planning is underway for the #ECOO14 Conference. Details will be displayed here when they become available.
#ECOO13

http://www.bringittogether.ca