Right Under your Nose

There are a lot of reasons to reinvent software. Maybe you don't trust the person who wrote it in the first place. Maybe you wrote it back when you didn't know what you were doing, but this time you'll get it right. Or maybe you didn't know that the solution was built already, right under your nose the whole time.

H. Y.'s colleague, as far as he could tell, fell into that third camp. He had a problem — he needed to read a value from web.config (an XML file that holds common settings for .NET applications, like authentication, authorization, connection strings, etc.) — and skipped past the research phase directly to solution engineering.

Had he not skipped the research phase, he would've discovered that all it takes is using ConfigurationManager.AppSettings["keyname"] to accomplish the exact same thing.

And this didn't stop him from skipping the research phase a second time — a similar function is in the same file a few lines down, except that it covers the connectionStrings section of web.config.

[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!

Featured Comments

So nobody here has ever written some code that had already been written, if only you'd known about it?

I've been in situations where I know there's a way of doing something, but no about of API/MSDN/Google searching comes up with what I need, so I write it myself. Then a few weeks later someone will say "you should have used xxxx" and lo and behold, yes I should - if I'd know about it at the time.

To all the apologists: if you're writing over a dozen lines to accomplish something that a moment's thought will show should be common and easy, you're definitely not spending your time right. This programmer did not do something obvious like typing "web.config reading" into Google, because they'd have immediately found what they're looking for in the first hit.

We've all had our moments missing an API that would have been useful and it doesn't make you stupid, but some APIs are definitely more obvious than others and reinventing the wheel is a lot less excusable in those cases.

So nobody here has ever written some code that had already been written, if only you'd known about it?

I've been in situations where I know there's a way of doing something, but no about of API/MSDN/Google searching comes up with what I need, so I write it myself. Then a few weeks later someone will say "you should have used xxxx" and lo and behold, yes I should - if I'd know about it at the time.

I admit, I have done this. I have since learned to talk to others. Evan as the senior member of the team, I would consult others about things they understood more than I did. You would be surprised what a design review meeting can accomplish.

I have noticed in software engineering that too much pride leads to too many WTFs.

(I am not criticizing you, Nick, just using your comment as a soap box)

So nobody here has ever written some code that had already been written, if only you'd known about it?

me:

Yeah, like programmers are supposed to *know* everything, right?

This is perfectly normal, the author just didn't know about some part of the API, contrary to what you may believe, it's not always discoverable.

Guys, let's revisit the first paragraph of the post, okay?

There are a lot of reasons to reinvent software. Maybe you don't trust the person who wrote it in the first place. Maybe you wrote it back when you didn't know what you were doing, but this time you'll get it right. Or maybe you didn't know that the solution was built already, right under your nose the whole time.

Notice the continuous use of "you": "Maybe you... maybe you... maybe you..." Obviously, the thrust of the presentation is that we have all done this and can relate! Nobody's pointing a finger and saying, "Look at him, he's so stupid..." We're laughing at ourselves and saying, "Oh, yeah, I've done that too!"

That's exactly the point: "Or maybe you didn't know that the solution was built already, right under your nose the whole time"

The first thing I learnt was the ubiquitous hello world. Delving into web.config was certainly not page 1 of the course notes. Just because you know something, doesn't mean that everybody else does, just as not knowing something isn't a WTF.

That's what the docs are for. I'm really sick of seeing yet another broken, homebrew, C-style string-to-int function in languages like C# and Java. As professionals, it's our responsibility to know and understand our tools (including language libraries) on a level where we can use them effectively and as they were intended.