Another idea for the C# editor
I was pitching this idea to the team about a new feature we could have for the C# editor, but I wanted to get your ideas on it. Whether you think it's good, or bad, or things you think it might do instead. If you liked it I would add it to that list we've been working on for things to add to C#.
Basically I've been trying to figure out ways to help users in two areas:. error correction and discoverability of code. Error correction seems like something we should be a lot better at considering we have an immense understanding of your code, and the context surrounding the error should be quite helpful in figuring out what you probably meant to write. Helping with discoverability should also be something we do considering that we know about the entire system. Basically, if we know so much, why do we help so little?
Part of the problem is that we don't want to be in your face all the time. Sometimes you just want to code and not be bothered. How many times do you get mad at Word because you're typing some stuff and all of a sudden it mucks around with it and you have to fix it? In our opinions that kind of interference could be a deal breaker for many coders. We've gone slightly against that model with 2005 to test the waters and get feedback from you guys as to whether or not you like it, hate it, or are just ok with it. We've done it in two ways. One is by bringing up a completion list automatically when you're typing an identifier, and the other is through the use of smart tags that can help you based on what you've just done with the code.
Bringing up a completion list automatically when typing an identifier seems like a pretty basic idea. You want to type “Console.WriteLine”, so you start hitting “C” and the completion list is up, the typing of “o” will get you to “Console” and you can know just hit 'enter'. When you get used to it it makes for some pretty damn quick typing. However, it can be a nuisance if you are doing something like typing a call to a method that doesn't exists yet. In that case you'll have to hit 'esc' to get the completion list to disappear. (This is similar with what happens in VS2002/3 when you have a completion list up because you hit <dot> and you type something that isn't in the list). One of the things we learned quickly with this feature was that if we didn't list all relevant information in a completion list then this would drive you crazy. For example if we didn't include “out” in the completion list when you were typing a method then instead of typing “out int param” you'd type “OutOfMemoryException int param” because the “o” would bring up the completion list and “out” would select that exception. Because of this we worked very hard to make sure that at any point in your code we would know everything that was valid to type at that point. The only times we'd screw up would be if you were coding in a forward thinking style where you were using things before you'd ever declared them (of course, we already screwed this up in the past, so we weren't too worried).
The smart tags come about in a few places. Mainly when we want to alert you that we could help you out based on what you've just typed. For example if you have a class called “Foo” and you go to the name, delete it and type “Bar” you'll get a smart tag that when invoked offers to rename all things that used to refer to “Foo” to now refer to “Bar” instead. Other examples are when we see that you've typed a method call to a method that doesn't exist. We'll offer to generate the stub of that method for you in the appropriate location. We'll also now give you a smart tag offering to add a using when you use a type from a namespace you don't currently have a using for.
In order to make these features truly useful we had to work very hard to make sure that at edit time we really had a very strong understanding of the system. This was necessary otherwise we'd just be in the way causing you to get code you didn't intend to write and also bothering you with unhelpful smart tags (i.e. a smart tag to add a using you already have would just aggravate you).
Because of these enhancements to the core architecture I was able to take the help one step further. Specifically I spiked a spell checker into the IDE. It has a few cool (IMO) features and I wanted your feedback on it. A picture might help out a little:
As you can see the smart tag is broken into three areas. The first two are the ones you might have already seen in the current releases. They offer, respectively, possible using‘s and fully qualified name replacements for the unbound item. The third area is new. It is the section that uses some heuristics to determine what you might have meant if you type a name that we cannot bind. As you can see, the spelling can be way off and we will still offer relevant correction. Also the replacement we offer does not have to be a type or namespace, but can be anything legal in C# at that point:
We do aggressive scanning of the system to see what you might have wanted to type, and we try to sort by relevance:
As you can see, we’ve found the your local variable “xmlReader” and we offer it first since it's probably the most relevant. However, that was the only thing in the close proximity that came close to what was typed in, so we broaden our search a bit finding some possible matches.
One thing to note is that there are two user interaction models for the spell-checking component of this smart tag. The first is to correct misspellings for names the user already knew about. The second is to help youexplore the system. i.e. if you're interested in XPath but they don’t know if we have any support for it. So you type XPath and immediately see a wealth of information. Yourealize we have a whole namespace dedicated to this which they can then “use” and explore using the rest of the in-code intellisense architecture.
I was thinking that because there are these two modes it might make sense to split the smart tag into two different things (see paragraph below). However it kind of makes sense here if you think of this smart tag as a method of resolving unknown names right at one central location. So rather than having to navigate away to add a using, or having to open object browser to find the right type, we offer the support right in the code and we offer support that no other tool in VS can give (i.e. finding names similar but not exactly like what you typed).
Something else I’ve considered is implementing this more akin to how Word does it with squiggles. i.e. type a name we don’t recognize and we underline it. If you right click then we offer the results right there in the completion set. However, I didn’t implement it this way because I already had the work done for this smart tag and I wanted to make this spike as light as possible.
What do you think?
Comments
Anonymous
June 22, 2004On the left column of the first dropdown picture, how about accelerators for pressing 1, 2, 3, etc. so that one doesn't have to slowly use arrow keys to get the 5th item. This way I can quickly realize "Oh I want System.Collections and to get this I press 4."
* Transparency. This would work very well for the normal Intellisense ("typing the dot brings up the menu") as well. It can sometimes be frustrating when typing to have the lines of text below you be hidden from view -- sometimes you need this text for various reasons. So this way you get the utility of the new feature, but it doesn't obscure your view of what you've already been working on. Possibly transition to opaque if the mouse moves into the drop-down's screen rectangle, and back to translucent if it moves outside again. This use of transparency is something I used to great effect in an app I recently worked on: not only does it look cool but it has honest-to-gosh benefits for the user.Anonymous
June 22, 2004
The comment has been removedAnonymous
June 22, 2004
Rick: Great ideas. I'll see how to work through the accelerator problem.
Transparency is also great. The debugger has it for the new tooltips. You hit ctrl and it goes to like 10% transparency, allowing you too what's underneath it. I'll see if I can add that feature to all of our UI that covers part of the screen.
Note: Hitting esc will minimize the smart tag back to "tickler" mode. Hitting ctrl<dot> will bring it up again.Anonymous
June 22, 2004
Cyrus, By the way, http://blogs.msdn.com/rickbrew ... that is the app I used transparency in.
Using ctrl to knock it down to 10% doesn't sound too bad actually ... that's a simple pinky finger away most of the time!Anonymous
June 22, 2004
Great. I really like this. And keep the smart tag. IMHO it's better than the underlining Word does. The transparency is a good idea, too.Anonymous
June 22, 2004
Rick: I'll talk to the editor team to see how to go about doing that :-)
Martin: Why is it better than the underlining?Anonymous
June 22, 2004
I think I like the underlining because most likely I will know that I typed it wrong and that will limit my selection to only suggestions... not the using or fully qualified items. I think they are two different interaction models.
Another question, is this going to slow my IDE? If so, would separating some stuff into a smart tag and some into the underlines mitigate some of that?
As for other interaction model, where you type XPath and see a wealth of information, isnt this better displayed in the dynamic help you have now? Does dynamic help use heuristics to come up with its information? Too be honest, I dont use dynamic help because it rarely give me enough information to warrant taking space on my screen.Anonymous
June 22, 2004
Cyrus,
I've not followed all the feedback you have tried to get from users.
I've to be sincere: coming from Intellij IDEA I simply cannot use VS2003 as is (of course a limitation of mine).
So I'm actually using Resharper.
I can focus my mind only on these clear consideration as a whishlist:
1 - I'd like to have a shortcut for a popup of the list of Namespaces/Classes/Methods/... if you get Reshasper working on an instance of VS2003 hit Ctrl+F12
2 - IDEA/Resharper both assumes the developer is smart enough and don't try too hard to interpolate the name or to correct it
3 - navigating the code (go to definition with a shortcut, implements interface, override members, GO TO IMPLEMENTATION when you are on an interface/abstract class)
4 - organize the using clauses (remove unused)
5 - when I write the name of a non already 'using' class, write the using for me
6 - restrict complete list only to scope reachable varables compatible with the expected type.
The IDEA is to have the developer master the code at the higher level possible (writing a misspelled name could mean 'correct me' or I'm expressing the intention to define a new class/struct/enum so don't correct me: help me create the class).
I'm not pushing Resharper, I'm only saying: see what it can do for a developer, please do that if you want to create a possibly better (at least for me) IDE.
I don't think you are too far to those kind of functionality.
Thank you very much for allowing feedback from usersAnonymous
June 22, 2004
Speaking about the general topic of completion lists: Are you going to handle the problem that sometimes the sheer number of members makes a completion list a bit annoying to use? Especially if you don't know the exact name of what you are looking for?
I wrote about a possible solution here: http://weblogs.asp.net/rweigelt/archive/2003/08/20/24637.aspxAnonymous
June 22, 2004
Very nice. I think I would prefer the squiggle approach as it would give a quick (and visually lightweight) view of code "correctness". Mistyped locals, type names, etc. would be readily apparent and easy to fix.Anonymous
June 22, 2004
Cyrus, what I'm curious about is, are these just image mock ups or do you actually have some demo code running on your personal build of the IDE. If it's the latter, it'd make for a cool blog article.Anonymous
June 22, 2004
Senkwe: What part of it would make a good blog article?Anonymous
June 22, 2004
Roland: I added that to the list of things people could vote for.Anonymous
June 22, 2004
Cyrus, what I meant was that since I don't have access to any version of VS 2005, I can't tell if these images are stuff currently in the beta or if you're running some specialized build on on your own machine and implementing this stuff as an experiment. So (assuming I'm not looking at photoshopped images) it would be cool to know how you're interfacing with smart tags inside the editor window and whether or not any of that type of integration is available to third parties as well as what type of performance issues you're facing and how you're overcoming them etc etc. Ok so maybe it's just me thats curious :-)Anonymous
June 22, 2004
Is the Enter key the only way to auto-complete/correct? I really like the ability to use Tab or <dot> to complete the entry (ala normal intellisense).Anonymous
June 22, 2004
The ability to customize it would be nice. Something more than turning it on or off all together.Anonymous
June 23, 2004
This Spelling and Grammar checking for C# has led me to another suggested feature idea... How about a "document contains errors" icon ala the Word Spelling and Grammar checking icon (the pen writing, check, x-mark on book icon towards the right hand side of the status bar). At a glance you can tell if the IDE thinks the code is buildable; and if there are any errors from the build. Double click on it to cycle through document errors like old school spell checking... as opposed to doing it TODO item at a time. Word also uses the context menu of the icon for temporarily hiding spelling and grammar highlighting (underlining).Anonymous
June 23, 2004
It's some-that bad idea.
This will increase pool of people who will start to code first, instead of think first. Once people has design specs and basic code stubs - they do not need correction like you propose.
Also I prefer to keep people who are unable to spell out override out of SD ;o)
As well it's impossible to type "overide" with current IntelliSence (it include all keywords in addition to classes).
Spell checking must be done only in comments/strings. There is already numerous spell-check Add-ins for VS.NET available from third-parties. They are trivial as they use Office API for dictionaries.
As well automatically adding "using" is nonsense. "Smart" IDE can add classes not relevant to context. As well - they not add Assembly references automatically if class used is not from currently available assemblies ?
I prefer C# team better focus on overall software process improvements (like a newly added TDD) instead of typos in code editor.
You need to focus how IDE will fit in overall SD process picture - Requirements, Design, Coding, Testing, Production, Support/Bug Fixing, Next Iteration
Small details like spell-checking must be given to third-parties using VSIP.Anonymous
June 23, 2004
The comment has been removedAnonymous
June 23, 2004
The comment has been removedAnonymous
June 23, 2004
The comment has been removedAnonymous
June 23, 2004
Senkwe: Ah, I see. I'll post later about the process I went about doing this.Anonymous
June 23, 2004
Ron: i'm not sure if <tab> will select something in the smart tag drop down. It would make sense for it to since it's the default completion character in most drop downs.Anonymous
June 23, 2004
Cleve: Two things. First, we would only include this if there were no performance overhead over typing.
Second. I would put it here instead of dynamic help because we're trying to be very code focussed. Many people disable dynamic help because they just want to use the editor. It also follows the model that we are providing suggestions for how to make your code correct.Anonymous
June 23, 2004
Frederico: What does ctrl-f12 do? You can already get a list of namespaces/classes/methods by hitting ctrl-<space>
2) We are not automaticaly fixing your code, we are offering suggestions when the code is wrong. You don't have to expand the smart tag if you don't want to.
3) We support "goto definition" "implement interface" "override members" "goto implementation"
4) I'm hearing a lot about cleaning up usings. It's something we'll look into.
5) This is what this feature does. When you use a class without having the "using" we offer to add the using for you.
6) This is a very good idea, we'll look into it.Anonymous
June 23, 2004
Roland: The large size of completion lists is something we are concerned with and we are thinking about ways in making it better. Thanks for the suggestions, they're excellent.Anonymous
June 23, 2004
Jason: How would you like to customize it?Anonymous
June 23, 2004
Mitch: Very true. We also want to be careful though with inundating you with squiggles and other visual distractions.Anonymous
June 23, 2004
Max: I believe we already have that support. You can disable or enable the error squigglies that we show. When you're showing them, f8 will cycle through them.Anonymous
June 23, 2004
AT: You're addressing one side of the features set. The other side is a way to help discover the system around you. Do you not like that either?
Also, do you not feel that the VS2005 team system software is helping out the software process?
We have tools to help you design, to help test, to help support, etc.
You say that we should help with coding. I would think that helping to fix mistakes and to discover the system would be part of that.Anonymous
June 23, 2004
Daren: Unlike Word, we would not be doing anything automatically. You would just get a smart tag tickler when we knew we could help correct a problem. ctrl-<dot> or the mouse will bring up the list and you can choose something from that.
The tickler is pretty innocuous so I don't think it will bother you.Anonymous
June 23, 2004
Duncan: I like the suggestion about unnecessary casts.
---
This feature will help you fix up the usings after you paste the code.
---
We provide support for implementing abstract methods.
---
I like the idea that we automatically add usings when you override a method. I'll look into that.Anonymous
June 23, 2004
The comment has been removedAnonymous
June 23, 2004
Frderico:
Ahhhh. Very cool :-)
This is something that we've also been discussing. A way to easily navigate the whole tree based structure of code.
Thanks for all the info!Anonymous
June 24, 2004
In VS2003 I often found a problem where you would be using a class, but because it's super class wasn't one of the imported namespaces you would only see the methods in the sub class. This greatly reduced the discoverability of methods in a class and often meant looking at the documentation to find what was needed only to see the class inherits from something that isn't imported. You get the idea.
There is a second problem which I think is related but I'm unsure how solvable it is. For example if I type SqlConnection I get prompted to import System.Data.SqlClient. Which is great except a lot of this namespace is very dependent upon System.Data, as soon as you create an SqlCommand and try and set it's CommandType (or anything similar) you are using items from the other namespace which when used writes out the fully qualified type with namespace. It's a problem of dependence and associativity. All the child namespaces below System.Data are very much tied to System.Data.
I've been thinking about information about classes. I would consider the core ones to be Disposable, Serializable (attribute or explict interface), Remotable?. It would be really useful
if these could be shown as small icons as part of the tooltip for the class to save on going to the documentation.Anonymous
June 24, 2004
Duncan: I agree taht we should do a better job pulling in all the dll's you need for full intellisense. THis can be quite confusing and irritating.
I like your ideas on IDisposable. I'm not sure about Serializable though. I like IDisposable because there are best practises associated with tat we should be helping you with.
How would knowing if something is serializable help you?Anonymous
June 24, 2004
Serializable helps in a number of situations, when I need to persist an object to a database, ASP.NET session state, Remoting request or an MSMQ body.
So when I'm looking at what objects may/may not be appropriate it's useful to be able to find out quickly if my intented object is seralizable.Anonymous
June 25, 2004
Duncan: Gotcha! Are there any other types you'd like to get specialized feedback on?Anonymous
June 28, 2004
The comment has been removedAnonymous
July 26, 2004
The comment has been removedAnonymous
July 26, 2004
The comment has been removedAnonymous
August 18, 2005
News on every hour. http://www.bignews.comAnonymous
May 28, 2009
PingBack from http://paidsurveyshub.info/story.php?title=cyrus-blather-another-idea-for-the-c-editorAnonymous
June 17, 2009
PingBack from http://pooltoysite.info/story.php?id=5941