Reflect on this

[firinmycsharp]If there's anything more pleasurable about programming .NET than Lutz Roeder's Reflector, then hand it over 'cause I'm gonna have dirty, dirty relations with it.


What's Reflector?  Well, its a decompiler.  That means I can open a DLL or an EXE and see all the code that makes up the program.  Why is that better (almost) than sex?  Well, that answer's twofold.

First, documentation is ass.  Nobody writes good documentation.  Nobody ever tells you what you need to know if you need to know more than just the basics.  For example, just now (this is why I'm posting), I was wondering if I could add a non-valid HTML attribute to a System.Web.UI.WebControls.ListItem's Attributes collection.  Who gives a fuck, you ask?  Well, I would if my custom control starts spitting out shit HTML that breaks rendering in your browser.

Anyhow, I checked the documentation for the AttributeCollection, which is the type of the Attribute property in the ListItem class.  And what did it say about how it implements AddAttributes?  Shit.  Bupkis.  Jack.  And out I whip Reflector.

Within a minute I had the code that some MS lackey (who was paid much more than me) wrote right on my screen.  And I can see that it passes whatever attributes I give it (all of which are strings--not too much type safety there) directly to the HtmlTextWriter passed to the AddAttributes method.

One more click and now I'm looking at the code where the html text writer actually writes the attribute.  What it all boils down to is I don't have to guess how it works and then do testing to make sure I don't break shit--I can actually see how the attribute value goes from my code through the ListItem to the AttributeCollection to the HtmlTextWriter and finally to the stream that's sent to the client.  Rock balls.

Second, you get to see how other people code.  People in big companies with policies about how code is written and tested and reviewed.  Stuff that my small company doesn't do--stuff we want to do, but can't do right now (we get better every day, tho).  Seeing good code is essential to writing good code.  Its practical knowledge that you can't get any other way.

Anyhow, if you're a .NET guy, get reflectin'.  And if you're not, start writing .NET code so you can get reflectin'. 

(Side note on Reflector:  You can't use it to decompile its own binaries, because Reflector.exe is obfuscated.  Its kinda funny, but also kinda dicky.  FREE UR CODE, LUTZ!!)

Programming Post by: McGurk at 08:00 PM | Reply
Kick this post:

Press butan, recieve imagelet. Hover for preview. Imagelets are pasted at the end of your comment. Think ahead.

Comments are disabled. Post is locked.