How Many Letters Are There in The Alphabet?
You saw the title and a single number came to mind. If you are English speaking your probably thought “26.” If your native language is not English you may have thought of other numbers though. Even in European languages there are letters such as é è ö ᴂ å ø. And that is just the start. So what does this mean to a programmer or a web developer? Well it means you have to be pretty careful if you are writing code to validate that only letters have been entered into a field. I recently read a series of email messages by someone who could not enter their name in a form because it included the letter “ö .“ That is a frustrating thing to happen. And honestly asking them to change the “ö” to an “o” is at best culturally insensitive and more likely outright insulting. So what is a programmer to do?
A typical, old school answer to looking for a non-letter in a string might look something like this Visual Basic code.
Dim t As String = TextBox1.Text.ToUpper()
For i As Integer = 0 To t.Length - 1
If t.Substring(i, 1) < "A" Or t.Substring(i, 1) > "Z" Then
MessageBox.Show("Alphabetic characters required")
Exit For
End If
Next
Looks good but if you test it you will find that all of those non-English characters that are letters are reported as not alphabetic. Not good.
Well often the best way is to rely on system/language functions to do it for you. One has to do their homework though to make sure those functions will do what you want though. I tried this C# code and it didn’t work. You’d probably not expect it to work if you are thinking about international letters because those other letters are outside the range of “A” to “Z” in most encodings. If you are not thinking about international letter this may feel right though. A reminder that testing is important.
{
if (t.Substring(i, 1).CompareTo("A") == -1 | t.Substring(i, 1).CompareTo("Z") == 1)
{
MessageBox.Show("Alphabetic characters required");
break;
}
}
Then I tried the IsLetter method in the Char object as follows and it works.
string t = textBox1.Text.ToUpper();
for (int i = 0; i < t.Length; i++)
{
if (!Char.IsLetter(t,i))
{
MessageBox.Show("Alphabetic characters required");
break;
}
}
This works because the IsLetter method understands what “a letter” is. Reading the documentation was pretty helpful here. This reminds me of one of my favorite things to say to students – reading the documentation is the shortcut!
There is not typically a lot of room in most high school CS curriculum of course but I think there is room to talk about it in context from time to time. It’s important that students start thinking about this early.
Oh one last tidbit from the recent email conversation I read – some people don’t have first and last names. They just have one name. Forms that require entering both a first and last name are problematic for them as you can imagine. Solving that problem may be a little more complicated. It’s something to start a conversation about though.
Source: Alfred Thompson
Interesting Links 13 September 2010
Lots of good links this week. And if you are visiting via the web I wrote a rare week-end post on Object Oriented Programming.Design that I hope you’ll take a look at. Also most of these links were sent out first on Twitter. You can follow me on Twitter at @AlfredTwo.
The speaker presentations from the 2010 CS&IT Symposium are now available at the CSTA web site. There are two that I had a part in including Computer Science, Game Development and the XNA Game Studio Platform where Steve Scanlan spends more of the presentation talking about how he uses XNA and game development with his students.
Download presentation as PDF (2 zipped files)
View streaming video of session
From @MSTechStudent is the announcement that Microsoft US is giving away an Xbox 360 console with the new Kinect each week to one random person who registered for the Imagine Cup. Visit the Imagine Cup US rules page and scroll down to MICROSOFT IMAGINE CUP "KINECT" SWEEPSTAKES for the details. And if you are a student sign up and put a team together.
I see that the people at iRobot are running a 20 in 20 robotics roadshow in Massachusetts. I’ve talked to several people at iRobot and they are serious about building interest among students in STEM fields. See their SPARK Starter Programs for the Advancement of Robotics Knowledge web site for more information about what they are doing for education.
Are you interested in teaching functional programming? Microsoft is offering their first F# in Education Workshop (Cambridge MA 5 Nov 201) and Don Syme (principal person behind F#) talks about the F# in Education workshop on his blog.
The Microsoft Office team announced the the Office.com 2011 calendar template contest which started last week see Office blog or the Calendar Template Contest Home Page for more details.
I found a post I really liked on the Blog@CACM blog last week – Old Geeks Never Die, They Just Get Grumpier I found this post to express a lot of how I feel about programming language wars and a lot of other sometimes heated discussions in computer science. Am I getting older? For sure. Grumpier? Maybe.
Charlie Kindel (on Twitter @ckindel) from the Windows Phone 7 system Tweeted “Remember Tetris for Windows (1991?!?)? DaveE wrote it. He also wrote this "Using the Accelerometer on Windows Phone 7"
Also related to Windows Phone 7 @MSTechStudent Tweeted about an essential guide for developers moving to Windows Phone 7 and C# from the Objective-C or Java languages and this XNA Framework 4.0 training kit.
Lastly my friend Peter Vogel @PeterVogel pointed out this good post on the CSTA blog CS Lessons From Facebook. If you are going to use case studies (and I’m a fan) you might as well use case studies that students can relate to. Facebook qualifies.
Source: Alfred Thompson
Most Popular Posts From August
It turns out the be complicated to figure out what the most popular blog posts are for a particular month. There are two sets of data I look through. One set, from Feedburner, shows (in theory) the top number of posts read by subscribers to this blog. The second set of numbers, from the hosting service, shows (again in theory) the top posts as read by web browsers. There is a lot of similarity in the two lists but it is not exact. For one thing the web traffic comes in large part from search engines. It looks like a lot of people in August were searching for things related to “What do you do on the first day of class” which led them to a post from September 2007! My posts from July of this year on Visual Programming languages and the new Microsoft Technology Associate certifications also received a lot of web traffic in August. The top 5 based on being on both lists is below though.
- Non-Myths About Programming
- Computer Science is NOT Boring!
- Free Microsoft Office Add-ins for Education
- Windows Phone 7 Sample applications
- Girls, Games and Software Development
I hope you’ll read through these if you missed them. Many of them have some comments which are often well worth the read. I encourage you to add your opinions to those and any other recent posts. And of course any I post in the future. Comments make it all much better for everyone. Are any of your favorite posts from August not on this list? Or any you think were worthless? I could always make a least popular list but somehow I think I would find that less personally satisfying.
Source: Alfred Thompson
Visualizations and Sorting
I love visualizations. One of my all time favorites are the programs that show how different sorting algorithms work. I was reminded of this by a recent post by Stacey Armstrong (CS News – What do sorts sounds like? ) with a link to a sorting sample that used sound as well as images. You can access the “What different sorting algorithms sound like” imagine at this link. These visualizations are really quite helpful for understanding how these sorts work. In fact writing them is a great exercise for students. But I get asked the question “why bother teaching sorting algorithms when most programmers use library or framework sorts. It’s a fair question.
If I want to sort an array named MyArray in a dot net language I will call the sort method of the Array object. That’s it. One call to a method with a parameter. It’s quick and easy for me as a programmer and the results are a very fast sort. In fact in every test I have done the framework sort method has been faster than any sorting algorithm I can write myself even when I use the best reference books I can find. Truth be told companies hire really brilliant mathematicians and computer scientists to create their library methods. Few can hope to do as well, let alone, better than these people. They bring outstanding brains and unparalleled training to the task. So why have students write sort algorithms?
Several reasons. One is just to study algorithms in general. Looking at different methods of sorting lets you discuss efficiency (think Big-O) using a problem (sorting) that students already understand. Though they probably don’t understand it as well as they think they do. It also helps to understand complexity of things that appear easy on the surface. Just try asking them how they sort things and watch them struggle to document the process. Along the way we get to explain related concepts such as searching (insertion sort), swapping of objects, loops and nested loops, and for several sorts – recursion! Quick sort is a much better example of recursion than Fibonacci sequence or Towers of Hanoi in my opinion. Students can more easily relate to sorting and that is one of the things that makes for a good exercise.
So it is not so much about the particular problem (sorting) as it is learning the tools and related (or sub) concepts. And if you use visualizations it can even be fun. Are you using visualizations for sorts or other algorithms? What do they look like? Are they working for you in your classes? Please share what works for you.
By the way, I do highly recommend Stacey Armstrong’s blog if you teach computer science. He’s been posting a lot of good stuff.
Source: Alfred Thompson
Interesting Links 6 September 2010
Happy Labor Day! Well here in the US anyway. Technically a public/work holiday and I do plan to spend most of it relaxing. Unless my wife has other plans that is. I spent yesterday doing some early fall yard work for example. But it looks good so it was worth it. I have spent some time collecting some of the more interesting links and bits of information I saw over the last week though. You can follow me on Twitter (@AlfredTwo) and see a lot of this sort of thing as I find it during the week. Also some conversation/chat with other interesting people about educational technology and other topics. Hope to see you on Twitter sometime.
Starting with a couple of community outreach pieces of news. One is that Microsoft has become a major sponsor of National Day of GiveCamp (on Twitter @GiveCamp) Give Camp is a weekend event where volunteer tech people from various companies get together to build tech solutions for non profits. Think of it as a computer age barn raising. Previous events have already helps a good number of organizations.
Also for nonprofits: Microsoft has launched its Elevate America grants program.
[…] the Elevate America community initiative, a new grant program that will support nonprofit organizations offering employment services, including technology skills training and job placement, in local communities across the United States. To support this initiative, we are committing $4 million in cash, $6 million in software and technology skills training curriculum over the next two years.
ITA Software is helping with a Massachusetts based Aspirations in Computing Award for high school women. See the MACAA Facebook page and follow @ncwitMACAA for more information.
Some interesting news on the Kodu front this week. The @koduteam announced that they have published an official Kodu language grammar. Very cool way to start understanding both what a language grammar looks like and what it specifically looks like for a graphical language like Kodu.
Kodu is also now available in German. Kodu in deutscher Sprache
Speaking of languages, there is now a Tutorial de Scratch en español / Scratch Tutorial (in Spanish). And apparently some are using Scratch to blend old and new by having students work with senior citizens.
Speaking of MIT, Scratch and that article above both relate to MIT, a bunch of people tweeted a link to the MIT Guide to Hacking
Sam Stokes writes about Adding shapes to your Windows Phone using some simple XAML and C# code.
See how a student aced his advanced programming course and got a game released for Xbox using XNA and Creators Club BCIT student creates Xbox game.
Most people use spreadsheets for real number, integers but fractions? How to work with fractions in Excel.
From XRDS (@XRDS_ACM) – the ACM magazine for students a comparison between Punch cards v. Java.
Last week on Twitter @compsciwoman announced a new blog called CompSci Woman and a post titled a minor in CompSci makes you surprisingly employable! Now isn’t that the truth!
Have you heard about the new Clorox grant program? You can win n up to $50,000 for your favorite school. You can play daily. Called Power a Bright Future. Some school is going to win.
Last link for the day Blue-sky thinking on Kinect and Xbox in education Some interesting thoughts from Anthony Salcito, Vice President, Worldwide Education, at Microsoft.
Source: Alfred Thompson