This post originated from an RSS feed registered with .NET Buzz
by Jonathan Crossland.
Original Post: CodeGen and Visual Studio Snippets
Feed Title: Jonathan Crossland Weblog
Feed URL: http://www.jonathancrossland.com/syndication.axd
Feed Description: Design, Frameworks, Patterns and Idioms
Code Snippets in Visual Studio is a form of CodeGen.
You have a template and its injected into your editor. I modify these quite a bit, mainly because I like my properties to have fields with an underscore and named the same as the property:
Here is my Prop.snippet (found in Tools|Code Snippet Manager|C#
It is a little different as this one matches the variable name with the property, puts the brackets how I want them and also puts my _CamelCasedField name.
Also now with Visual Studio.NET 2008, we have a Code Snippet Editor to make life easier.
Yeah, I know its longer, and some like the bracket on the top line {
} like that, but thats the way I like it. Who can argue? I know someone who still prefixes everything with str_, int_ and so on. We are all different.
Round Trip Engineering (RTE) for Code Snippets
I believe, the next generation of code snippets, and CodeGen as a whole, should have rte capabilities. using Code snippets as an example, when we embed a code snippet, in our code, it should always understand that it was/is a code snippet. That way we could change the variable and have it change the expression in the code snippet. In fact this is simply refactoring, but keeping the Expression and code snippet metadata is an important step.