Fog Creek Software
Discussion Board




Taking the easy way out

So I am sitting at home, working away on my project. However the program keeps putting a single space at the front of the output.

I have spent about an hour chasing down that space, where did it come from. I have figured out that it has come from a class that I have written, the class is returning an extra space in front of a string. I have about another hour ahead of me to finish tracking down this space. One measly little space. How frustrating.

So how tempting is it to have taken the easy way out back when I realised that the program was outputting an additional space.

myString = mid(myString,1,len(myString)

problem solved.....

Now place this in a firm of 100 hundred coders, and the additional space is coming from code written by some in another division, and well, it is no wonder you hear stories of cruddy code and weird work-arounds.

Even if I was sure I would still be the type of person to track down that mesaly single space, I can't be sure management would love to see a day wasted on the effort, or the other coder/division would appreciate it.

Control is nice, I like being small.

Aussie Chick
Monday, February 16, 2004

Alternatively, this is one of the reasons that many new development philosophies espouse "no code ownership". Everything should be known by at least 2 people, and anybody should be able to fix anything, any time.

Brad Wilson (dotnetguy.techieswithcats.com)
Monday, February 16, 2004

found the little thing!

Aussie Chick
Monday, February 16, 2004

>> found the little thing!

_Do_ tell Shere Hite for her next book.

Sorry, couldn't resist :-)

Fred
Tuesday, February 17, 2004

ROTFL, Fred.
good one.

anonQAguy
Tuesday, February 17, 2004

You should set a breakpoint which triggers when that string is modified, and only when the first char of the string is space.

In Borland Delphi, I can do this.

Maximus
Tuesday, February 17, 2004

I can set breakpoints when debugging standard exe's, but I am writing a Word Add-in (ie a DLL), and I haven't figured out how to debug this in the same way as with a standard exe.

Aussie Chick
Tuesday, February 17, 2004

"Now place this in a firm of 100 hundred coders, and the additional space is coming from code written by some in another division, and well, it is no wonder you hear stories of cruddy code and weird work-arounds."

you are exactly right aussie chick.
Code rot begins when its easier to hack in a feature or fix than it is to redesign correctly.
Unfortunately that point is reached almost the second the initial design/coding phase is complete, its one of the signs of a _good_ programmer that they can balance carefully the ease and speed of putting a fix/feature in with a hack with the long term benefits of doign it properly.
Its made even harder by the fact that, in the short term, its usually safer to use a quick hack as well as quicker, because it actually 'touches' less code and so theres a smaller chance of breaking something else.
Obviously over the long term (or even medium term) making the decision to use a quick hack leads to real problems, while in the short term it has real benefits.

the best programmers IMO are those who can judge which approach to use in each case, taking the advantages and disadvantages of each approach into account.

IMO its best to add fixs and features 'properly', _except_ when its best to do it using a quick hack :)

FullNameRequired
Tuesday, February 17, 2004

Exactly the same way, if you're using VB. You may need to set binary compatibility. You may need to start the project with the DLL running, *then* launch Word.

Justin
Tuesday, February 17, 2004

>Its made even harder by the fact that, in the short term, its usually safer to use a quick hack as well as quicker, because it actually 'touches' less code and so theres a smaller chance of breaking something else.

This crossed my mind, I actually wondered whether I had written some code (using some 'split' functions) to take the extra space into account and therefore skip the first string in the array resulting from the split function.....

Thankfully I hadn't, but I remember at uni how they never liked us hard coding anything, and making sure every function worked flexible. I can see why now. All for a little space.

Aussie Chick
Tuesday, February 17, 2004

*  Recent Topics

*  Fog Creek Home