Thursday, October 29, 2015

Learning By Teaching

One of the best things about teaching is students asking questions that never occurred to you. I learned several new things today. Students always seem to have a new take on things. They look at things differently.

I try to encourage students to be innovative in their projects. Sometimes the questions they ask are easy and indeed obvious. One student asked me how to find the default color for a command button in a Windows Forms. I knew there had to be a way to find it and there is (SystemColors.ButtonFace for what it’s worth). It’s useful information to have though it is more a platform question than a computer science question. That’s ok though.

Then as a student left class he asked me about the name property of an object that is part of an array of objects. He wanted to know if the system automatically assigned a name to objects created in arrays at runtime. That’s one I hadn’t though about. After all one accesses these objects as part of the array and we tend not think of these objects as individuals with their own names.

If an object is created first and added to an array the name is still available and usable independently of the array. That is pretty much what I would expect. One wouldn’t expect a name created at compile time to “go away” at run time.

It turns out that if you are dynamically adding objects, like buttons, for a Windows Form there is no name assigned by default. You can assign a name property but using it to access the object seems to be problematic. I’m sure there is a way but I’ve not been sufficiently motivated to look for it.

Still it is a concept worthy of discussion. It may be as much philosophical and computer science.  We may talk about it in class tomorrow. In the mean time I learned something and have something to ponder. That makes for a good day.

No comments:

Post a Comment