Wednesday, December 9, 2009

Is CBMunger ready for prime-time (I should I bother?)

I posted this to Stack Overflow a month ago. The gist of the replies was (1) Huh? What? and (2) run it up the CodePlex flag pole and see if anyone salutes. It could be a daily blog topic, the method of the day -- but so many are so mundane -- but nonetheless useful.

---- The question on Stack Overflow ----

It was my second C# project, undertaken years ago, and it has lived on, because (imho) it is Genuinely Useful Software. It's also badly designed and the code is embarrassing.

It runs C# code. You write a method, the method name appears in a listbox, you double-click the method name to execute it. That's it.

Examples:

When I open up my C# web project at work, a method runs a couple command-window apps my project needs, and checks to confirm that the requisite service is up. I never have to remember that stuff.

I hate UPPERCASE, so I have a method that lower-cases SQL, but preserves the case of quoted strings. Another method calls a web service to beautify SQL. Those both operate on the clipboard.

One method fixes the names of MP3 files: title casing, replacing underscores and hyphens, optionally removing/inserting text or prepending numbers. Creates a playlist!

I double-click to harvest all of my Twitter links, turning them into an HTML page with hyperlinks and a jQuery-powered search.

A method searches the specified log4net.log for every operation that took longer than the specified number of milliseconds.

I can create a restore point by double-clicking a method (and open up the corresponding dialog with another method).

When my wife had to write some sorting algorithms for school, the utility was an ideal testbed. I use it to test bits of code all the time.

None of these methods is in any way impressive. No large brain stuff. Most of it is just string manipulation, file system operations -- mundane stuff. Handy though!

This morning, I wanted to format some SQL output as rows in an Excel table. I wrote a method to read the output and format it as tab-delimited columns, for import into Excel. I have no idea how else I could have done that. It took about 8 minutes to write.

I have 300 methods, perhaps 50 of which are often useful, the rest there if the occasion arises. Occasionally I move the real cruft into the Zaps group, so it's out of the way.

The utility has lots of ease-of-use features. I prefer the keyboard to the mouse, so methods are tagged into groups that are accessible from a dropdown: control-T selects a different group. Don't remember the group? You enter control-F to find all the methods matching a string. Arrow down and press to run the method. The parameters window always remembers its state: if you entered Hoytster last time, it's there this time. You can right-click a method to see its tooltip; double-right-click to see its source.

I tried to make it easy to create new methods quickly.

A method generates your new function's prototype: you enter the method's name, group tag, tooltip, etc, and the new method is created with the requisite attribute decorations. The prototype is placed in the clipboard so you can paste it into one of the utility's source files.

It's easy to prompt for parameters:

...GetParameters("*Target File", "@Report File", "Open Report [No, Yes]");

opens a window with textboxes labeled Target File and Report File, and an Open Report checkbox with text that toggles Yes and No. Strings in curly-braces become radiobuttons. The Target File must exist, because of the initial asterisk; the parameters window will not close if an invalid target file is entered. The Report File must be valid (it CAN be created) because of the @-sign.

When you run the method and the parameters window appears, it has a [Capture] button you click to generate the code needed to capture the returned parameters, putting it into the clipboard again:

string targetFile = parameters["Target File"]; ... boolean openReport = parameters["Open Report"] == "Yes";

Ach, I go on too long.

So, how ambitious should I be? CodePlex? Maybe a dedicated web site, where people can upload their methods?

Getting the utility publish-ready would be a lot of work. I have to clean up the code; remove the really dumb methods and the never-finished methods; create a screen cast of the "make a new method" process, document the teeny "meta-language" (tongue-in-cheek) that drives the parameters window.

I like the idea of y'all using my utility to be a bit more productive. I love the idea of seeing what methods you invent and share. No doubt it's out there, but I'm not aware of places on the net where people share code as simple as a method "Fix the names of my MP3s".

Would you like to have this utility?

Besides being overworked and lazy, I have never put up a web site (!) -- and y'all might mock me because my GetParameters() method has about 200 lines (my poor excuse: I started out with FORTRAN). This utility was never designed; it accreted. :)

So let me know: Do you think this utility is useful enough to put up on CodePlex (or somplace)?

Thanks in advance! - Hoytster

No comments:

Post a Comment