Don't Pollute User Space

What is user space? User space is the location in the filesystem where users put their personal files-- their "stuff". Here's the user space folder structure in the Windows XP operating system:


This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2008/01/dont-pollute-user-space.html

So you’re saying I shouldn’t have these auto-created folders called “Visual Studio 2008” and “SQL Server Management Studio Express” under “My Documents”?

Amen. And yes sam, that’s exactly what he is saying.

Argh, yes! I’ve got:

  • Code Snippets
  • Fax
  • Fiddler
  • My Code Snippets
  • My Games
  • My Weblog Posts
  • OneNote Notebooks
  • Scanned Documents
  • Snippet Compiler 2008
  • Visual Studio 2005
  • Visual Studio 2008

You have a strange idea of what “user space” is. I think most people would agree with wikipedia: http://en.wikipedia.org/wiki/User_space

Totally agree, and while I haven’t really thought about it so deeply, I generally lean toward getting rid of programs that do it. It’s tough enough to clean up my own messes when I know what is in My Documents.

On a tangentially related note, it’s good to see that with Vista we drop the convention of My this and My that, at least for these folder names.

Vista makes this easier, but what are you supposed to do in XP? For example (this happens to be something I had to deal with personally) Vista provides a User\Saved Games folder, very handy for making it easy for the user to manage saved games themselves outside of our game. Microsoft’s Games for Windows requirements demand that users easily have access to saved games in both Vista and XP. However, Application Data is hidden from the user by default, so there’s no easy way to tell a user, for example, where to find saved games and replays to upload to the net if they’re in a hidden folder. The suggested solution from Microsoft is to store them in My Documents, in a folder of your own creation, for your game.

App Data just isn’t appropriate if you want your users to be able to find data files on their own machines, so I have to disagree with you on this point (at least when working with XP.)

Under the “My Documents” folder on my WinXP box, I currently have the following unrequested folders for game saves…

  • Bioshock
  • My Games (holds game saves for Crysis)
  • Ubisoft (for all Ubisoft game saves)

I know there were more there before I reformatted too. Damn Windows…

Well I hope this does awaken developers to the existance of it. Just this week I finished explaining to a co-worker (developer) about the use of environment variables in Windows (knew they existed but that is about where it stopped). On my Vista box I have variables for APPDATA and LOCALAPPDATA - not to mention the Isolated Storage facilities provided by .NET.

That being said, it can be abused (painfully, I am looking at you Adobe) - but overall it is a very clean way to manage things, and makes backup/restore a relative snap.

Who puts their files there? I have whole hierarchies of file paths that I have been using for over 10 years. Some stuff starts in \Chris, other stuff in \Corporate and other stuff in \Temp. I guess I could do what MS says to do, then do something else next year, then something else the year after that. I type a lot of my paths when opening files (because it keeps defaulting to that damn “My Documents” shite), so very, very little actually goes there.

Forgot to mention. If Windows would let me preceed a path with “~” to indicate whatever the “user root” du jur is, I might be able to live with that. Again, reinventing UNIX, badly.

This is not just about the user space.
What about the other random places where programmers keep the data?
I have seen programs that keep data in the windows folder, the system or system32 folder and other creative and imaginative places.

And I have seen “encryption software” that stores the password in plaintext in the windows folder in a file named “sys123.d”

I suppose 50% of the programmers are only 50% programmers.

I totally agree that almost every application data should be kept in the Appdata folder.
And then there is an issue of polluting the registry.

I think this is actually a larger failing in Windows rather than just an issue of developer guidance - there’s no good location for storing user accessible application data. Take, for example, Visual Studio code snippets. I want to be able to install them, copy those between machines, back them up and restore them, etc. Burying them in AppData isn’t a good solution - that’s an opaque store that isn’t even visible (never mind decipherable) to users by default.

You know, it might not be such a mess if they’d just pick a damn naming convention and stick with it.

Surprisingly enough, a lot of the entries in the Documents folder are from Microsoft’s own programs.

Folders from other software:
Cakewalk
CyberLink (PowerDVD)
EA Games (The Sims 2)
My Google Gadgets (hey, I uninstalled that…)

Folders and files from Microsoft:
MSDN
My Music
My Pictures
My Recieved Files
My Shapes (Visio, even has a custom icon)
My Videos
OneNote Notebooks (about the only thing I’d consider “forgivable” for saving in My Documents)
Visual Studio 2005
spider.sav
default.rdp (hidden)

And that’s not to mention the programs (oh look, Visual Studio 2005) who hard-code the directory and get it wrong when I redirect it in the registry.

I think it’s safe to blame Microsoft for this state of things.

Doesn’t worry me - I use an entire drive for my personal data. Screw “My Documents”. All the litter in My Documents has made it necessaray to continue the practice in the name of backwards-compatability, thus forever tainting it to really be “My Misbehaved Program’s Documents”.

User can tamper with environment variables. Use the CSIDL values and related API calls instead to locate paths.

What if you’re creating a setting archive that might be needed to be used by a different log-in than the log-in that the file was created under? Esp. with Vista, what choice do you have than to put it in a All Users\Documents type folder?

A better don’t do this would be to not place important files in hidden system folders. The authentication software that my company currently uses (and is being phased out) does that very thing in Vista. Now that’s bad behavior.

Raymond Chen discussed the CSIDL vars that hmm mentioned above.
http://blogs.msdn.com/oldnewthing/archive/2005/07/01/434647.aspx

eric: Jeff is not talking about user ‘process’ space. He probably used the wrong term, but I am sure he knows what he is talking about.