The Wizard knows best

I suffer from the old programmer’s “anti-bloat” mentality: get rid of things that are unnecessary. After all, the file that’s never used is just taking up precious hard drive space, and is potentially confusing. There’s no need to keep it, having it clutter up the project directories and revision control system, and sitting there unused in the distribution directory. It’s just good sense to delete it. Right?

I used to complain, when creating a new C# program, that Visual Studio would barf all over my hard drive, creating a bunch of files and directories that I just didn’t want. I wanted the tool to create projects my way, not the way some goon at Microsoft decided it should be done. It took me a long time to realize that I’d be a lot better off if I just accepted the defaults. Binaries go in bin\Debug and bin\Release. The obj directory has stuff that I don’t need to care about, etc. It took a while, but after a time I realized that the Visual Studio project structure works. It’s perhaps not what I would have designed, but it works just fine.

And then I created an MVC Web application. And I thought a new Windows Forms app barfed all over my hard drive? Ha! An empty MVC application has so much crap that I’d surprised if any one person could say with certainty what all of it is for.

I created an MVC Web API project a while back. Apparently, most Web API applications also have a browser-based interface. The MVC Wizard creates the site so that browser requests go to /app/controller/action/, and API requests go to /app/api/controller/action. That seems reasonable, but I was told that my application wouldn’t have a browser interface and that all my API requests should go to /app/controller/action. That was easy enough to change, and I finished the project. Then I made a big mistake.

As I said, the MVC Wizard barfs out all kinds of unnecessary stuff: help pages, JavaScript, references to Entity Framework, service providers, and I don’t know what all else. I figured I could save myself a lot of trouble with versioning and deployment if I removed all that stuff. And it worked. My project was lean and mean, easy to deploy and with no extraneous files.

But then I was told to add some browser-accessible pages.

I won’t regale you with all the things I attempted over the day I spent trying to add all that stuff back to my project. I went home very frustrated that evening, wondering how I was going to accomplish the task. In the shower the next morning, I decided that my best course of action was to start over with a new MVC application, let the Wizard barf all over my hard drive again, and then just make the modifications I need, leaving all the extraneous crap that I have no use for. It took me approximately an hour to duplicate my application that way.

When it came time to modify another application that I had “optimized,” I didn’t even try to re-add the stuff I’d deleted. I just created a new MVC application and made my changes. 30 minutes later, I was done.

The Wizard knows best. Let it do its thing. If it creates stuff you think you don’t need, just grumble if it makes you feel better, and then get over it. Do not try to “optimize” by removing from the project those things you think you won’t ever need. If you don’t want them cluttering up your distribution directory, then modify your deployment script so that they’re not copied. But don’t remove them from the project. You’ll be sorry if you do. Trust me.