The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Code Snippets should have Context

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jonathan Crossland

Posts: 630
Nickname: jonathanc
Registered: Feb, 2004

Jonathan Crossland is a software architect for Lucid Ocean Ltd
Code Snippets should have Context Posted: Jan 26, 2009 7:16 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Jonathan Crossland.
Original Post: Code Snippets should have Context
Feed Title: Jonathan Crossland Weblog
Feed URL: http://www.jonathancrossland.com/syndication.axd
Feed Description: Design, Frameworks, Patterns and Idioms
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jonathan Crossland
Latest Posts From Jonathan Crossland Weblog

Advertisement
"A revolution for editing code in .NET"

One of the most common Code Generation tools involve databases and are called O/R Mappers. This is going to change with the likes of OSLO and DSL's. But historically, Object-Relational Mappers have been the predominant force in CodeGen and they are usually CRUD based. (create, read, update delete) They come in various flavors and I have not used one before now that I still use today. That is, I could never find one that gives me enough freedom to design and implement my project the way I need to, and very quickly I leave them behind. Most have limitations, and don't actually do what it says on the tin.

For example, more than most try to sell you the idea, that it removes the database from you, you can talk to it via the objects, however, I have never found one, that I have not had to go “under-the-hood” to modify a Stored procedure or some aspect of the generated code. So if you do choose to use an O/R mapper, you must be sure, that you can make changes deeper down in the generated code. CodeGen is not good enough yet, to be a black-box tool

But thats one flavor of CodeGen. Other flavors involve Wrappers, Code Snippets, Designer Tools, and general utilities that can generate entire projects and/or layers and everything in between. This post, I would like to concentrate on Visual Studio .NET Code snippets.
Visual Studio.NET Code Snippets currently have a few problems. No editing tool, no built-in way of designing snippets easily. It is one way. It injects the snippet into the Editor and when done, forgets everything about the Expressions. The Refactoring Engine and the Snippet are not friends. They do not communicate.

Code Snippets

Lisa Feigenbaum - Code Snippets in Visual Studio
Ken Levy takes his camcorder over to interview Lisa Feigenbaum and get a look at the new Code Snippets feature in Visual Studio.

Code Snippets Solution applied to all code files, LIVE

A Code Snippet should not “lose” knowledge of the parameters/expressions. Anytime, I click on an Expression (example: PropertyName) that was inserted with a Code Snippet or NOT, it should still understand it. Refactoring would be automatic. Why should it be two separate tasks? Have you ever changed a Property Name, without wanting to change where its referenced?

Consider adding the “prop” Code Snippet. It asks you for Field and PropertyName. Now I believe that this is “kind-of” there for Visual Studio 2010.

But the key missing ingredient, is having our code “always aware”, especially of “expressions”. If you click on a Field it should highlight and as you make the rename change, it should alter your references automatically.

But a Code Snippet is only a small utility, but I wanted to use it as a small example of how code snippets need to keep context and knowledge of its injection, and in the same way Code generation in general has to be able to do this too.

If you generate a class for my person table in a database, and I change the class name, it should, by means of Code Snippet Expressions, Refactoring Engine, understand and align the change across to the database and the the code that references it.

Read: Code Snippets should have Context

Topic: Extensible Objects in WCF Previous Topic   Next Topic Topic: Building My Own Music for PodCasts

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use