Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

September, 2010

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    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

    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");

    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");

    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.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Objects When? If Ever?


    This post started as a comment on Mark Guzdial’s blog (Moti asks: Objects Never? Well, Hardly Ever!) but I decided to elaborate some. I think this is an important discussion to have both in education and in industry. Mark’s post was inspired by an article by Moti Ben-Ari Objects Never? Well, Hardly Ever! | September 2010 | Communications of the ACM. (That is premium content so if you are not an ACM member it will not be fully visible – sorry about that) The key comment from the article is probably:

    I claim that the use of OOP is not as prevalent as most people believe, that it is not as successful as its proponents claim, and, therefore, that its central place in the CS curriculum is not justified.

    In computer science education today it is taken pretty much as an article of faith that object oriented design is THE design paradigm to teach. The only debate most of the time is when in the curriculum to introduce it. It took me a while to grok OOP. I'm old school and remember the move to structured programming in the early 70s. There was a lot of discussion back them about having to bend designs to make them fit the “new” structured methodology. Programming  languages changed to reduce that problem but the "go to is bad" argument still remains - albeit somewhat underground. :-) But by and large the benefits were obvious enough that structured programming "won. We got a lot of good things from this change. Loops became more powerful and flexible for example. Design got easier and program maintenance got much easier.

    Some say that OOP is the next step but I'm not so sure. I think it is an additional step that can co-exist with other paradigms. Proponents want to replace other ways of designing software and that is where the object first or objects later debate comes in. There is a third way that is to use objects in parallel. This argument that gets lost in the shuffle though. That is the school of thought I find myself in.

    The way I see it objects fit into more traditional programs and make some things easier. Making everything an object often adds unnecessary and even unhelpful complexity to what can be simple designs. One only has to look at "hello world" written as an OOP program, say in Java. Compare that with the same in old languages like BASIC or even dynamic languages like Python. I don’t see why objects can’t be used with great efficiency when appropriate in a more traditionally designed program but always and for everything? Not so sure about that.

    The problem as I see it is that objects are great tools for what they are good at but poor tools for many other things. Everything doesn’t have to be an object. Not every target in carpentry is a nail and so you need other tools than hammers. Programmers should be about having a full toolbox and not a limited one. To many people this means knowing multiple programing languages and I agree with that. I also think that programmers should be comfortable with multiple paradigms. That means functional programming as well as procedural or object oriented. It means that people should be able to use multiple tools (languages and paradigms) in the same over all project. Why not use F#( a functional language) along with C# and Visual Basic and maybe even Iron Python (a dynamic language) in the same project? Use the right tool a the right time. (This is easy with Microsoft’s .NET framework and Visual Studio of course. I’m not sure how easy it is in other tools and platforms.)

    Anyway I am tired of language wars. You may want to read Old Geeks Never Die, They Just Get Grumpier on the Blog@CACM to better understand that point of view.

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Imagine Cup–Solving the Worlds Problems Through Software


    There are many indications that today’s students are motivated as much, if not more, by the chance to make a difference in the world as they are to make money. By the same token it is not always obvious or clear to these students that computer science and software has huge potential to do a bit of both. But in fact computer science is making a big difference I the world and could potentially make an even larger difference. This is the logic behind the Imagine Cup, arguably the world’s premier student technology competitions, basing their theme around the UN Millennium Goals. The goal of the Imagine Cup most briefly is to:

    Imagine a world where technology helps solve the toughest problems


    So what is the competition? Actually a series of competitions and challenges that open the doors for multiple types of solutions in different areas of interest.

    The top event is the Software Design competition to create real-world software applications using Microsoft technologies. The Embedded Development event involved using a provided embedded platform and the  Windows Embedded Compact Framework to create a new and innovative solution to a real problem. The Game Design competition is about creating a game that helps teach, provide access to more people or solve other real world issues. Last year one of the top teams in the US was a high school team BTW.

    The Digital Media competition is all about “your big idea could enlighten folks around the world about major global issues.” Photos, videos, music – no matter what form of digital media you are into are you thinking about how you can use your skills to change the world?

    The IT Challenge is for students who love to play with the hardware and software mix. “The object of this challenge is to highlight the art and science of developing, deploying, and maintaining IT systems that are efficient, functional, robust, and secure.” Round 1 is a series of online quizzes. take as many or as few as you’d like and score 15 or more on one of them to move to the next round. There is even a practice round you can try today.

    Now to be honest and upfront, most of the competitors are college and university students. So it can be a daunting for a high school student to put together a team. But while winning is always a goal there are other benefits of competing. For one thing it is a chance to push yourself to the limits of what you know and move past them. Are you up to university work? Beating out a bunch of college students would show that even if you didn’t beat them all. Are you looking for something that sets you apart from other high school students looking to get into a good college? Well showing the admissions office that you have the drive, the ambition, the skills (like communication and leadership) to work with a team through a major international competition should be a good start.

    And maybe you will win. What events should you look at? Well a lot depends on your interests. If you are an IT student learning systems and network management you should really try to test yourself with the IT Challenge. Are you a digital artist than give it all you have in The Digital Media competition. Are you a programming student than the Game Design may just be your thing.

    Are you up to the top of the line Software Design competition? This one requires a real time commitment. Are you up for it? Few high school students are with all they have going on in their lives. Are you and your friends the exceptions?

    Of course if you are in college or university this is your chance to go up against the best and brightest in the world. No excuses if you want to show the world just how ready to change the world you are!


Page 1 of 6 (18 items) 12345»