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

July, 2011

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Small Grants for CS Education

    • 1 Comments

    If you are involved in K-12 computer science education you really owe it to yourself to join the Computer Science Teachers Association (CSTA) And if you are a member of CSTA than you received this announcement in the last week or so. But just in case you are not a CSTA member (yet right?) I thought I should post this CSTA Blast for your information.

    ACM's SIGCSE (Special Interest Group for Computer Science Education) has a small grants program (up to $5000) for member projects in CS education, and that this is a good time to think about it.

    Almost any material development, study, or other work likely to be of interest to the SIGCSE community is eligible for consideration.

    You can see examples of past projects, as well as details of the proposal process, at http://www.sigcse.org/programs/special/

    The next round of proposal reviews is slated for mid-August, so if you have something in mind this is the time to start fleshing out a proposal (on your way home from ITiCSE, but before you start writing your Symposium papers :-). Submit proposals via email to apply@sigcse.org; anything received by August 15 will be reviewed in the mid-August round.



  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Encapsulation–An Introduction

    • 0 Comments

    My good friend Sam Stokes posted an introduction to Encapsulation not long ago. Not that I am competitive mind you but I thought I could do better. Smile And since I had some vacation time in which to think and write I have given it a try. I’ll let you judge if I succeed or not.

    So what is Encapsulation? Encapsulation is an important part of object oriented programming. It is part of what makes OOP “safer” and more easy to use. Briefly stated Encapsulation is the hiding of implementation details of a class. Specifically you include the data storage as private data and create methods that interact with that data. The implementation of these methods is not visible to the programmer who uses the class. Nor is the internal representation of the data. Everything is in this software capsule – this “black box” that just works. One fun example is a die class (Die being the singular of dice in this case. Nothing to do with first person shooter actions)

    Of the several benefits of encapsulation are that data cannot be directly manipulated by code that calls/uses the object and that the way methods work can be changed without negative impact on other code that uses the class/object. Let’s take a look at this in code with the first part of a very simple Die class (This example is in Visual Basic but the concepts are the same in other programming languages)

    Public Class Die
        Private sides As Integer
        Private face As Integer
        Private rnd As Random
     
        Public Sub New(ByVal s As Integer)
            If s < 2 Then
                Throw New Exception("Sides must be greater than or equal to 2")
            End If
            sides = s
            rnd = New Random
            face = rnd.Next(1, sides + 1)
        End Sub
        Public Sub New()
            Me.New(6)
        End Sub
    The first thing of note is that our data is declared as Private. This means that these variables are only visible and modifiable from inside the class. Code that calls an object of Die class can not access sides, face or rnd directly. They are “hidden” – this is what we mean by data hiding. Are two constructors, one which allows the specification of the number of faces the die has and one that creates a default die with six sides, can manipulate the data but do so transparently to the user. The non-default constructor does some simple data checking. In this case it only allows the creation of a Die with two or more sides. This is for the user’s own protection. Notice that the default constructor calls the non-default constructor. This is not required but is a good idea because it means that the actual setting of face happens only  once and with proper data validation happening in one central place. We also only need to set the initial value of the Die in one place. User access to the data happens through methods. As we see below.
     
    Public Function Roll() As Integer
        face = rnd.Next(1, sides + 1)
        Return face
     
    End Function
     
    Public ReadOnly Property FaceValue() As Integer
        Get
            Return face
        End Get
    End Property
     
    Public Overrides Function ToString() As String
        Return face.ToString()
    End Function
    Class

    In this example we only allow the user to get (and change in a protected fashion) the face value of the Die. The property FaceValue is read only – we do not want the user code changing that to some value of its own choosing. In fact the only way to change the value is to call the Roll function/.method which uses random values that are (theoretically at least) outside the user’s control. The ToString method is likewise only a way to get the face value.

    In our example there is no way to retrieve the number of sides the Die has and fixing that would probably be a good edition. Like FaceValue that would be done as a read-only Property.

    In our example we could substitute any algorithm for changing the face value of our Die that we wanted to as long as it returned an Integer value within the range expected by the user code. While we are probably not going to write our own random number routine we could and it would not require any changes in code that used this Class. In other applications being able to change the algorithm used in a method without having to change code that uses it could be  a valuable option. It would allow us to test various algorithms for performance, accuracy, or other values quickly and easily. In a payroll program we could make changes in the calculations for bonuses, overtime or any number of things within a single class without having any negative impact on programs that used that class. That’s a big win in ease of testing and debugging. It’s all made possible by encapsulation.



  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Interesting Links 25 July 2011

    • 0 Comments

    I was on vacation last week. I had no Internet or cell phone access for a week. It was wonderful as I really needed the break. Don’t we all need a break now and again? Yes there were posts all week I wrote them in advance so people who were bored would have something to read. This week I will be headed out to Redmond (yes, the travel continues for a bit longer) where I will be part of the 2011 U.S. Partners in Learning Innovative Education Forum (IEF). I am excited about this for a number of reasons. One is to meet all of the wonderful and innovative teachers who are coming from around the US. Only a very few of them have I met in person already. Also in attendance as judges will be my friends Vicki Davis, Pat Yongpradit, and Steve Dembo. Vicki Davis is the award winning teacher behind the Flat Classroom Projects, the Cool Cat Teacher blog and more. Pat is an outstanding computer science teacher who won the world wide Innovative Educator award last year. Steve writes the great Teach 42 blog and works for Discovery Education. But mostly they are really great people who care about education. In the mean time my co-workers at the partners in learning group have been blogging in advance of this event. A couple of recent posts are listed below and they will be blogging the event at the Teacher Tech blog.

    USIEF

    Well in spite of being on vacation last week I do have a few more links to share. So here they are:

    Mark (@guzdial) Guzdial writes about “Why does CS count towards high school graduation in Georgia?” An interesting story about graduation requirements, college admissions requirements, some politics and some good solid activism.

    Computational Tales CS concepts written as fairy tales.

    I highly recommend Doug (@dougpete ) Peterson’s CS & IT wrap up post.

    Interesting post by Lee Stott Have you seen .NET Gadgeteer really cool fun for making serious gadgets.  I’ve seen Gadgeteer and it really does look like it has huge potential in education.



Page 2 of 8 (23 items) 12345»