Wednesday, February 23, 2011

Hacking Together Good Code Quickly

I'm kind of a perfectionist when it comes to writing good code. I'm not saying that I write amazingly perfect code all the time. However, I do take pride in writing good code and always over-analyze (not in an OCD way, but...) my architectural choices when designing systems.

Well, it's officially crunch time on a project that I'm working on, and I'm forced to add features into the application with the quickness (ie. hack). :( It's not bad code. It works. However, it is not written to my standards and has some majore "code smell" to it.

Things like this:


DoSomethingCoolHere();

foreach(var form in Application.OpenForms)
{
if (form is AnalyzerForm)
((AnalyzerForm) form).RefreshDisplay();
}


I would much prefer to NOT use the 'Application.OpenForms' static property, nor would like to cast objects to specific types to call a method on them. However it works for now, and can be refactored later. At least I can take comfort in knowing that I get to refactor as soon as the "facade" is working.

These are all the secrets that I'm going to expose right now about our amazing software. :)

No comments: