Last week the Microsoft Visual Studio Middle School Toy was announced and I wrote about it in my blog. Today I wanted to give people a taste of what one of the features – the Visual Declarative Designer – looks like. This one really deserves the “toy” designation. In fact writing some code that does similar things might actually make an interesting assignment. Well except for the fact that this add-on actually includes the generated code directly into the program in the IDE. Making that work would be a whole lot more of a trick. 🙂
Any way, what does it do? It allows a user to specify information about a variable or structure and automatically generate the code for it and include it into the program. It works for both Visual Basic and C#. The image below shows it at work for C# and generating a declaration for an integer array.
As you can see a limited set of the most commonly used variable types are supported – Int, String, Boolean, Array (of Integer or string) and Struct. Two dimensional arrays are supported and if you want you can have the tool automatically generate some random values for your array. This is a C# example of course but it works the same way for Visual Basic.
If you declare a Struct as in this image below (Visual Basic example this time) you can add any number of integer and/or string fields.
This is a starter tool and most students will outgrow it rather quickly. But it can be used to demonstrate how to create variables with a minimum of confusion with the syntax. Learning the syntax of things that should (and are once you get it down) be easy to do can be a source of frustration for beginners. And of course someone who knows one language and wants to learn another on their own may find that this helps them pick up the basic “how to I create/define a variable” question very quickly. And if I can confess something … with all the languages I have used over the years remembering how to declare an array when I have been away from a language for a little while sometimes takes me a few more minutes then it used to when I was younger.