Writing software, the wrong way

Sunday, April 6, 2008

Overcomplicated

While doing some test cases for the javascript wrapper around registry keys, I found a major flaw in an assumption I was making about keys that made me rethink my code. While I made some things simplier, it was still a pain to get something. Here is a progression of how things used to be and how things are right now.

Declare the service :
let service = Cc["@shacknet.nu/winregistry;1"]
.getService(Ci.nsIWindowsRegistryService);


Oldest way :
let key = service.getKey(
Ci.nsIWindowsRegistryService.ROOT_KEY_LOCAL_MACHINE,
"Software\\Mozilla\\Firefox\\Crash Reporter\\EmailMe");
let answer = key.getValue();
key.close();


Older way :
let key = service.getKey(
"Software\\Mozilla\\Firefox\\Crash Reporter",
"EmailMe");
let answer = key.getValue();
key.close();


New and simplier :
let answer = service.getKey(
"Software\\Mozilla\\Firefox\\Crash Reporter",
"EmailMe");


I figure, this will work for 100% of the use cases right now. I was gonna get complicated with making another, more complete, interface for getting attributes of keys (ie. what was the root, path, and key name). But this early in the process, especially without requirements, I don't care about it :)

No comments: