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

May, 2011

  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    Returning Data From A Second Form

    • 0 Comments

    The other day I received a query about using second forms in Visual Basic. I found a link to some examples and passed it along but it left me unsettled. The teacher in me did not find those examples explanatory enough. Sample code along is ok as far as it goes but often beginners need more. In fact I tend to prefer more myself. So I set out this morning to create an example. While I was creating an example for Visual Basic I decided to create an example for C# as well because, well, why not? What this example does is to instantiate a second form which is a simple implementation of an input box. The input box includes a textbox for data entry, a cancel box (I keep wanting to label this “never mind”) and a Done button. It looks like this:

    image

    Exciting right? I believe that examples for beginners should be very basic. I’ll use this form for both code examples. The textbox is called txtInput. The buttons are btnCancel and btnDone which should all be self-explanatory.

    If you want to load your own custom form in .Net the first thing you have to do is to create that form. I do that from the Project menu option and selecting Add Windows Form. Since I want to return data I need to create a property. This property (of course you can create several if you want) will allow the calling program to get data from the form. In this case I am using a simple string property like this:

     

    ' Create a string property using newTextValue to hold the data privately
    Private newTextValue As String
    Public Property newText() As String
        Get
            Return newTextValue
        End Get
        Set(ByVal value As String)
            newTextValue = value
        End Set
    End Property

    The C# version might look something like this:

    // Create a string property using newTextValue to hold the data privately
    private string newTextValue;
    public string newText
    {
        get { return newTextValue; }
        set { newTextValue = value; }
    }
    Now to use our form we have to declare an instance of it and ask it to show itself.  Let’s say it our form/class is called MyInput.
     
    ' Declare a new object of type MyInput which is a form
    Dim testCase As New MyInput
    ' Declare a string variable to save the return from the form
    Dim MyData As String
     
    ' Show the second form as a dialoge box
    testCase.ShowDialog()
    ' Get the information from the form we just called
    MyData = testCase.newText
     
    ' Display what was returned
    MsgBox(MyData)

    Why do we have it display as a dialog box? That is to make sure that our main program don’t go off and keep doing things before we are done with the second form. Our code in C# might look like this BTW:

    // Declare a new object of type MyInput which is a form
    MyInput testCase = new MyInput();
     
    // Declare a string variable to save the return from the form
    string MyData = null;
     
    // Show the second form as a dialoge box
    testCase.ShowDialog();
    // Get the information from the form we just called
    MyData = testCase.newText;
     
    // Display what was returned
    MessageBox.Show(MyData);

    I hope the comments are detailed enough. That is more comments than I might put in a real program but I think having them here helps explain what is going on a little better. One last thing, if you find this example more useful than what ever else you may have found please think about linking to it so that more people can find it. Thanks.



  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    University Computer Science Faculty Blogs

    • 0 Comments

    I read a lot of blogs. Perhaps too many. But there are a few blogs I could not do without. I thought I might do a series of recommendations on different types of blogs and suggest some of the best to my readers. I thought I would start with a couple of blogs by computer science faculty members from a couple of universities. There are probably more good blogs out there than these but these are the ones I never miss because of the great content, the quality of the writing and the fact that they have content approachable by people like me (i.e. people comfortable teaching high school students.) So in no particular order here are some suggestions.

    Mark Guzdial – Georgia Tech, GA, US Computing Education Blog

    Mark is probably doing more research in how to teach computer science right than anyone else I know. His posts include information about the CS Principles course, he is on the advisory board, which will probably be a new APCS course. He talks about the work they are doing at Georgia Tech both in terms of teaching new and different courses there as well as the Georgia Computes! program that is helping to develop more CS education at the HS level in Georgia. I wish I wrote half as well as Mark. Whether if be his commentary on the various articles he finds or information about his own work or discussion of  things his graduate students are doing what you will find here are well thought out, well written and informative posts. His are the first posts I read most days.

    Eugene Wallingford, University of Northern Iowa, IW, US Knowing and Doing

    Eugene writes a lot about the things he does in class and I find this very informative. Teaching and Learning is the top item in his blog categories list. Computing and Software Development as close behind. This is another blog I like for its well thought out and well written posts. And like a lot of Mark Guzdial’s posts, the posts here often make me think. And I am always learning from this blog as well. From insights into pedagogy to societal issues in computing I find a lot of value in this blog.

    Gail Carmichael, PhD student at Carleton University in Canada The Female Perspective of Computer Science

    I like this blog for its perspective and for the insights she shares from the courses and workshops that she teachers. She also does research in augmented reality and has good knowledge of games as teaching tools. And of course gender equity, something I care deeply about, is something she is well qualified to write about. So I learn a lot.

    Rob Miles – Hull University, UK Rob Miles' Journal

    The first thing you have to know about Rob is that he has a great sense of humor. The second thing is that he knows what he is talking about with regards to game development and programming for mobile devices. Rob has written a lot of good curriculum resources and is one heck of a speaker. On his blog he shares a lot of his resources as well as a lot about his life. This is not all tech all the time by any means. So if you take things too seriously read about the other blogs here. But for me I enjoy his travel talk and outstanding photography as well as the insights into teaching and software development. Rob is one of the first bloggers I ever started reading and I enjoy his work a great deal.

    A couple of other good university faculty blogs for you  to take a look at:

    • Jim Huggins Kettering University – I just started following Jim more recently but like what I read so far.
    • Existential Type Robert Harper, Carnegie Mellon University – Very technical and I don’t always follow everything


  • Computer Science Teacher - Thoughts and Information from Alfred Thompson

    What Can You Do With What You Know?

    • 0 Comments

    We’ve all heard the saying “It is not who you know but what you know.” While the truth of that can be debated in some cases when it really does seem that people get opportunities because of who they know in most cases what matters is what one can actually produce. The problem for companies though is determining who can actually be productive. There is an interesting blog post by Jay Evans on Tech Crunch called Why The New Guy Can’t Code that is very critical of hiring/interview processes. Jay is not impressed with certifications and degrees and believes them to be fairly useless in the hiring process. He is looking for accomplishments and believes that “Certificates and degrees are not accomplishments” jay is not the only one to worry about the disconnect between academic learning and industry needs. I wrote about a professor trying to teach for the interview back in February - Teaching, Learning and the Job Interview. It is a fair question to ask if teaching to the interview is much better, in terms of finding the right new hires, than teaching to the test is for really evaluating how much a student has learned.

    What it all boils down to is not theoretical knowledge or even raw intelligence but what can someone actually do with the knowledge that they have. Oh and how do you demonstrate it. How does jay define an accomplishment? “I mean real-world projects with real-world users. There is no excuse for software developers who don’t have a site, app, or service they can point to and say, “I did this, all by myself!” ”

    There is some truth in this too. If you want to be a game developer and that is really important to you hiring managers are going to ask to see the game or games you have created. That already happens today in most game development companies. If a student (potential employee) claims to be a great web designer asking them to explain some HTML tags seems like a half-way measure compared to asking to see a portfolio of sites created. For other programmers I always ask “what sort of projects have you done on your own – things not required for a course.” Ideally I want to hear about something that wasn’t finished in a week or two or five. I want to hear about a serious project that tool a long time and forced the applicant to learn new things. I want to know how they go about learning those new things, how they deal with design problems that develop, and I want to hear the satisfaction of a big project completed.

    Mark Guzdial has some concerns about the “only interview people with accomplishments” philosophy (It’s all about the app — or is it?) and I can understand his concerns. But I think that a lot depends on what you are looking for in a new hire. If you are hiring a designer it is quite acceptable to expect them to show a design that they created but that someone else implemented. This is where multiple person teams can really come into play in creating real accomplishment. Team activities have an advantage of demonstrating the ability to work in a team. This is a highly valuable skill in industry today and hard to interview for unless there are examples of the process to talk about.

    Frankly all of this controversy about interviews, accomplishments and finding ways to demonstrate that one can actually use their knowledge to solve a problem – to accomplish something – shows the value of long form development competitions. This is why the Imagine Cup competition is something that students outside the US really go all out for. Oh we have some great US teams and I look forward to seeing them compete against the best of the rest of the world in New York City this summer. But American students don’t seem to take on large out of class projects they way students in some other parts of the world do. I would really expect to see a lot more US competitors in the Imagine Cup.  I don’t know if there is a perception difference between the need to demonstrate ones accomplishments, different work loads in different universities, or some thing else. What I do know is that at Microsoft at least seeing a great Imagine Cup project impresses people. While not the only game in town its an event well worth participating in.



Page 6 of 9 (27 items) «45678»