Welcome to MSDN Blogs Sign in | Join | Help

PM Duties Episode IV: The template strikes back...

One of the things I own for the C# team is the project system. For this, I'm what's known as a relationship PM, which means that I'm responsible for something but there's no C# team that does project system work. My job is to figure out what the C# user needs and drive them to the VS Core project team.

There are lots of good things coming, most of which I can't talk about until PDC. One thing I can talk about is the C# project templates, which control what you get when you create a new project or add a new item to an existing project. So, I've been looking at what code you get, and deciding how to change it.

Here's the VS 2003 version of a console application:

using System;
namespace ConsoleApplication1
{
	/// 
    
    
        /// Summary description for Class1. /// 
    
    class Class1 { /// 
    
        /// The main entry point for the application. /// 
    
    [STAThread] static void Main(string[] args) { // // TODO: Add code to start application
    here // } } }

 There's a lot of cruft in that template. Here are my notes:

  1. The namespace provides little utility at all, as you never refer to this class from outside.
  2. The XML comment for Class1 is useless, for the same reason.
  3. Why "Class1"? How descriptive is that?
  4. The XML comment on Main isn't useful, because Main is private and can't be called.
  5. The XML comment on Main provides no useful information. If you don't know that Main() is the entry point for an app, then you aren't going to be helped by the comment.
  6. The command line args aren't used by most apps.
  7. The TODO comment is really, really useless. It's mind-blowingly useless, like the directions that are on toothpick boxes, or the label on my blow dryer that warns me not to use it when sleeping. I'm trying to picture the scenario. There I am, working on my console application, and it doesn't work. I'm perplexed. What should I do? Do I need to run the debugger? Should I call a co-worker over? Maybe I'll check the task-list first. Oh, here's a TODO comment, and it says that I need to write some CODE to make my application work. Thanks, Visual Studio.

Here's the Whidbey version:

using System;

class Program
{
	static void Main()
	{

	}
}

It's just a tiny bit cleaner.

I'm making similar changes to the other templates, get rid of useless comments and just generally simplifying things. Windows Forms projects will now use partial classes, with the user code in one file and the designer code in another file.

Note that these changes will not be present in the PDC bits, but will show up in the beta.

 

Published Tuesday, August 19, 2003 12:31 AM by ericgu
Filed under: ,

Comments

Tuesday, August 19, 2003 1:13 AM by Jeff Key

# RE: PM Duties Episode IV: The template strikes back...

THANK YOU! I had considered calling my lawyer for a carpal tunnel lawsuit against the VS.NET team for having to constantly delete all of that useless cruft (bravo!). It's great to see you folks are hitting the "little" stuff, too.
Tuesday, August 19, 2003 1:41 AM by Jerry Dennany

# RE: PM Duties Episode IV: The template strikes back...

Oh, you have my everlasting thanks for this!
Tuesday, August 19, 2003 1:54 AM by Ricky Datta

# RE: PM Duties Episode IV: The template strikes back...

Dude, The tabs are best set at 4. Ricky
Tuesday, August 19, 2003 2:16 AM by Roland Weigelt

# RE: PM Duties Episode IV: The template strikes back...

I agree with most of the ideas to cut down the templates, but don't get rid of the "string[] args", because newsgroups will be flooded by the question "how to I access the command line arguments", "are command line args not allowed anymore", etc. Sounds crazy? Believe me, it will happen... Roland
Tuesday, August 19, 2003 3:16 AM by Julian Gall

# RE: PM Duties Episode IV: The template strikes back...

If it's so obvious to Eric that the new template is better, and presumably to everyone else on the VS core project team, why was all that stuff put in in the first place? Credit to the team for removing the cruft but, hey, they put it in there too.
Tuesday, August 19, 2003 3:29 AM by Ryan Heath

# RE: PM Duties Episode IV: The template strikes back...

Hey?! Where did that namespace go? Is it allowed for a class not to be declared in any namespace? Didn't know that.
Tuesday, August 19, 2003 3:49 AM by Graeme Foster

# RE: PM Duties Episode IV: The template strikes back...

Looks neater, but don't underestimate how helpful the TODO is for newbies. Also it shows up in the Task List so you can see when you've forgotten to do it.
Tuesday, August 19, 2003 3:58 AM by Simon Smith

# RE: PM Duties Episode IV: The template strikes back...

That's nice. Putting the WinForm generated code in a separate file is the first reasonable excuse for allowing classes in multiple files I've heard (my opinion only!) In fact it's so nice can that be done for Web Forms also?
Tuesday, August 19, 2003 4:29 AM by Marco Russo

# RE: PM Duties Episode IV: The template strikes back...

Uhm... for the newbies comments, namespace, string[] argument and TODO... all these stuff are good to introduce the presence of that function. Now, after a while you want to get rid of that, and the best would be an option that eliminate all the cruft. Otherwise we will start to see classes declared in the global namespace (ok, for the Main it doesn't matter, but it is common for someone starting to write a component inside a test program and then move the source code in a library). Just to add another topic, a debatable "feature" of VS.NET is the Version attribute in AssemblyInfo.cs... It's misleading for someone who want to write a shared assembly, even if in the general case (private assembly) it has no side effects.
Tuesday, August 19, 2003 6:55 AM by Anonymous

# RE: PM Duties Episode IV: The template strikes back...

Oh, great. Thanks a lot Eric for these changes that no one but your dreamed up and asked for. Now who says that VB.NET and C# are really different, after all this?
Tuesday, August 19, 2003 8:18 AM by Rodrigo B. de Oliveira

# RE: PM Duties Episode IV: The template strikes back...

Great thing but I wonder what keeps you from integrating something like CodeSmith (http://www.ericjsmith.net/codesmith/) into the IDE? This will give us users all the benefits we could possibly want from a code templating system, it's configurable, it's very easy to write our own templates on (hey, we didn't forget what you did with the Visual C++ 6) and so on and so forth... Please, don't tell me you don't have the resources (or hire me then! :-))...
Tuesday, August 19, 2003 10:59 AM by Jeff Lewis

# RE: PM Duties Episode IV: The template strikes back...

I agree with Roland above... Please leave the string[] args in the declaration. Too many people don't know how to get them any other way. Additionally, how many CONSOLE programs don't use the command line arguments? I can't think of a single one that I have ever written that didn't take command line args even if it was just /?
Tuesday, August 19, 2003 1:53 PM by Rich

# RE: PM Duties Episode IV: The template strikes back...

Big kudos to this idea. I want to put my vote in for leaving the 'string[] args' in, too. And, the idea of having a 'beginnner' and 'no-what-I'm-doing' mode to turn the comments and all on/off seems valuable.
Tuesday, August 19, 2003 1:54 PM by Tobin Titus

# RE: PM Duties Episode IV: The template strikes back...

I love this idea, and thank you for it. For those of you that want your templates to include these items, you can still edit your templates. These are found in you [Program Files]\Microsoft Visual Studio .NET 2003\VC#\ directory. You can edit the templates to not include items you dont' want, and include items you do want. This is what we have had to do in the past if we wanted the "features" that Mr Gunnerson has mentioned.
Tuesday, August 19, 2003 2:15 PM by Jim Argeropoulos

# RE: PM Duties Episode IV: The template strikes back...

I use regions all the time, so I would love to see a way to tell the system to always put in these namespaces. Okay, so yes, I have options today. I can modify the template, and I can put the text in the toolbox and pull it off of there every time (I take the latter approach because it is less invasive). But it would be nice to have a way to add my own customizations separate from the "standard" template. I am in favor of keeping the namespace, the args. I say yes to loosing the comments. They only thing they buy is a reminder that those important features exist.
Tuesday, August 19, 2003 3:44 PM by Peter Caven

# RE: PM Duties Episode IV: The template strikes back...

Eric, I can certainly sympathize with your efforts to make the template cleaner, but I think you might be under-estimating the amount of hand-holding that a new user really needs. Regarding: using System; class Program { static void Main() { } } as an experienced developer, I can write that myself in about 2 seconds - it's no help at all to me.
Wednesday, August 20, 2003 4:36 AM by Adrian Bateman

# RE: PM Duties Episode IV: The template strikes back...

While some of the stuff you've removed is clearly superfluous, I think you've gone too far removing all the comments and command line arguments. Please put some back in - the templates are mostly for helping beginners and as has been already noted, there will be a flood of questions generated by the things you've dropped.
Wednesday, August 20, 2003 7:25 AM by Mary Branscombe

# RE: PM Duties Episode IV: The template strikes back...

maybe you could try that out on a couple of newbie programmers - wander over to some of the contract testers for the Windows Media group or do some HCI testing to find out how lost a beginner will be with no point of entry to the code. If you want to strip it back that far, shouldn't it be an option (verbose on/off) in VS so they can move on when they're ready? As a journalsts who gets a lot of feedback from entry-level users and still remembers being utterly stumped the first time I wrote VBA, I think you may need to feel your way back down to beginner level a little? ;-)
Saturday, December 18, 2004 10:56 AM by MBA

# MBA

Helpful For MBA Fans.
New Comments to this post are disabled
 
Page view tracker