Monday, December 18, 2006

Process Snobbery

As an idiot, I'm used to getting goggle-eyed looks and incredulous gasps when people are introduced to the depths of my idiocy ("What do you mean you've never [insert random programming task here]? What kind of developer are you?"), and that's fine. I mean, everyone has their standard for what makes a "Real [insert profession here]," so I find this small, everyday bit of snobbery easy to ignore. It just so happens that I seem never to meet anyone's standard for what makes a "Real Developer." But one related bit of everyday snobbery that I do find frustrating is when certain activities or processes that aren't fixed or standardized across enterprises are treated as if they are standardized, and I subsequently get treated as an even bigger idiot for not somehow knowing a given group's processes without having ever been told what they are.

I mean, take functional specs as an example; I'm yet to see two companies that do functionals exactly the same. Yet when I do a functional at one company, they look at me goggle-eyed and say, in so many words: "That's not how to write a spec! What's wrong with you?" I then fight to learn their way of doing it, only to go to my next gig and go through the same thing. It's gotten to the point where I just point-blank ask people how they do specs (among other things) ahead of time to spare myself the embarassment. I mean, I'd rather have them just think I'm an idiot up front and get it over with, rather than struggle through trying to guess how they want things done and looking like a really colossal idiot.

Now, to reiterate, what bugs me here isn't that everyone has slightly different ways of doing the same thing, 'cos that's to be expected. What's frustrating is that even though everyone does it differently, they all seem to expect me to produce a perfect spec for them on the first try without them first telling me how they like it to be done, as if a functional spec was a constant across all enterprises and once you've done one, you've done 'em all. It's a no-win situation, really. Even when I ask ahead of time how a given client wants things done I still come out on the short end of the stick 'cos then they think I'm stupid for not knowing and having to ask.

I swear it feels like the upper-echelon developers have a secret club where everybody magically knows how to do everything exactly right the first time. Only, I know that's not true (duh), 'cos I hear the high-end capital-T Talents bitch endlessly about each other all the time. So what gives? Just once I'd like to have a tech lead or architect say to me "Okay, we need you to write a spec, and here's how we do specs at this company..." and then give me an actual explanation before expecting me to start churning things out. Sure would make life more pleasant.

Friday, December 15, 2006

How An Idiot Developer Solves a Problem, Part 1

The situation: I have a "contact us" web page where the list of available subject lines changes depending on what the user selects from the "who do you want to contact" drop-box. While my department is responsible for code, content is controlled by another person in a different department, and that person is going to need to be able to add and change subject lines with as little pain as possible. They'd also like to be able to add new contacts.

The thought process: I know the person who's going to be editing the page for the foreseeable future, and she's comfortable with HTML, but not with programming. I could probably get her to be cool with entering everything into an XML config file, which would allow easy deployment of new data, and be cool; because developing with XML is always cool, right? However, any new contacts she'd want to add would have to be added to the database, requiring intervention by DBAs anyway. Unless, of course, I don't use that particular database table. This is a standalone site, and one of my mandates is to make this site as hands-off as possible for developers. So if I teach the content owner how to edit an XML file, and put everything in there, effectively bypassing the DBA group, then she gets to maintain control of the content, and developers hopefully won't have to get involved so much. Also, I've heard reports that using the current method, where she edits .asp pages directly, that she's accidentally messed up code or sent the wrong file for updating. So if I do this via XML maybe that'll reduce both types of errors.

Okay, so I'll make a config file. What's at the top of my heirarchy? These things are grouped by Categories, so we'll make that the root, containing individual Category elements:

<categories>
<category>
</category>
<categories>

Lesseee, then I guess it'd make sense to have an element describing who to contact, and what the name of the category is:

<categories>
<category>
<name></name>
<contact></contact>
</category>
</categories>


By the way, I name my elements as simply as possible, i.e., one word and lower case, whenever possible because not only am I an idiot, I'm lazy, too. Now what to do about those email subjects? I could make a new file, I guess, but for this app they're bound to the category, so it makes sense to me to make them children of the category element, just like name and contact:

<categories>
<category>
<name></name>
<contact></contact>
<subject></subject>
</category>
</categories>

...and of course I can have as many subjects as I need. I'll never be transmitting these xml files as far as I know, so I'm not gonna bother writing a schema right now. I suppose I'm violating all kinds of xml best practices here, aren't I? I should probably have written a schema first, and my grammar is awfully specific. I mean, it's one thing to write an app-specific grammar, but my grammar is specific to one page of one app. That's gotta be wrong in all kinds of ways, but I'm gonna do it because it's quick, and solves my current set of problems in what I think is a reasonably elegant way.

See, this is what it's like to be an idiot programmer: I really do mean well, and I want to solve this problem in the most elegant way possible, where elegance doesn't just mean I'm programming elegantly, but that I'm also being politically elegant by making all the people happy that I need to: I'm getting done quickly using existing tools, I'm not bothering other developers and am trying to reduce further bother, and the content owner gets to keep her content. However, I always feel like there's a piece I'm missing: like there's probably some super elegant, abstracted way to do this such that the xml is reusable and infinitely extensible, and the app could be ported anywhere without any code reworking going on. But I need to get this done now. So on I go.

So but so anyway now I have an xml file. What do I do with it?

To be continued...

Tuesday, December 12, 2006

Writing FxCop Rules Is Really Hard Without Any Documentation

So here at work I'm currently doing lots of .NET stuff. Recently I was tasked with writing some custom rules for FxCop so we can enforce our coding standards before check-ins and builds. Unfortunately, there seems to be a dearth of FxCop Custom rules, and an even greater dearth of information about how to write them. Apparently a developer named Raymond Lewallen came right out and asked "where are the custom FxCop rules?" in Feb 05, and it seems there's still not much of an answer. If you go to the GotDotNet UserSamples area and look for FxCop samples, the results are pretty grim; fewer than 20 results, and almost nothing for the newest versions.

That wouldn't really bother me -- experience has taught me to take online samples with a grain of salt, anyway -- except for that fact that there also doesn't seem to be thorough API documentation or an SDK, and according to the FxCop FAQ on MSDN, this will continue to be the case for the foreseeable future.

So I continue to slug it out on my own. Things take a little longer for me than it probably does for most programmers, but I've managed to get a solution put together and a rule or two (all very basic and borrowing heavily from Microsoft samples) written that are working against a really simple "Hello World" console assembly. I figured out the whole where-do-I-put-my-xml-file-and-what-do-I-call-it issue through some painful experimentation and forum scouring, but when I write something like...

LocalList locals = method.Instructions[0].Value as LocalList;
InstructionList instructions = method.Instructions;


...which I got from one of the sample rules, I really have no idea what I'm doing. I can make certain inferences based on usage, but I don't know what a "local" is, or what "instructions" are, really. Is a local like what's in the "Locals" window in VS? Are instructions lines of code, or literally instructions, not to include declarations? I suppose the best way to find out, lacking an SDK (or whatever), would be to download the source code, but I don't think it's publicly available right now, or at least it doesn't appear to be. Hm. Back to trial-and-error, I guess. Maybe this is why I'm yet to work at a shop that uses any custom rules; all anyone seems to do is turn off a few of the default checks and run it like that.