Login to participate
Register   Lost ID/password?
Louis Kessler's Behold Blog » Blog Entry           prev Prev   Next next

Avoiding Tangents - Sun, 8 Feb 2009

Splitting the one big routine that creates the Everything Report into pieces involved a number of challenges. The hardest thing to do is to keep myself from going off on tangents.

An example of this just happened as I tried to reprogram the part that displays the titles of each section. These sections are internally numbered sequentially. I use what is known as a linked list to store them. A linked list simply links the first section to the 2nd, the 2nd to the 3rd, etc.

When the entire report was produced, Behold followed the list through and generated the sections. But now by only displaying what is visible, I need Behold to go directly to a specific section. The problem is that there is no index to get directly to that section’s information in the linked list.

I then remembered seeing an article a while back that said that a TList in Delphi is as fast as a linked list and can provide direct access to any specific item, e.g. the 43rd one. So off I went trying to change my linked list structure into a TList.

I took several attempts at this. I first started just changing the code and there were a lot more places the section info was used than I had thought. Some of them were tricky to change, and I started not trusting myself that I made the changes all correctly.

So I started again and did it more carefully. This time, when I ran the program, I got an error. I found out what it was and fixed it. Ran Behold again and another error at a different spot. Hmmm. Still no good. Two errors here is too much. Doesn’t give me confidence in what I did.

So back again I went, this time deciding to change one thing at a time and keep the program working all along. I did a couple of steps before I stopped to think about what I was doing.

My assumption here was that I needed direct access to section info. Why? Because following the linked list to get to the section would take too long. I could maintain a reverse index instead which would be another solution.

Again, this thinking was to enhance an entire algorithm. Something’s not right here about what I’m doing. All I really want to do is simply finish this bit off and go onto the next step to get a new very-much optimized Behold out and into beta.

This tangent I was on was entirely based on thinking that non-direct access would take too long. One of my very large test files had 6,000 report sections. So I tried it. I clicked on the very last report section and faster than I could blink, Behold showed the section. Following 6,000 links takes no time with Delphi. I should have realized that.

It’s funny. I’ve been programming for more years than I can remember. And I’ve got quite good at doing it efficiently. But sometimes that mental block sets in, and the obvious becomes elusive.

2 Comments           comments Leave a Comment

1. Brett (brett)
Australia flag
Joined: Mon, 12 Jan 2009
36 blog comments, 59 forum posts
Posted: Sun, 15 Feb 2009  Permalink

So how is March 2009 still looking for the next update to the prgram?

2. Louis Kessler (lkessler)
Canada flag
Joined: Sun, 9 Mar 2003
237 blog comments, 226 forum posts
Posted: Wed, 18 Feb 2009  Permalink

It’s still my goal. Unless I set myself an ambitious goal, it’s hard to keep pushing.

Leave a Comment

You must login to comment.

Login to participate
Register   Lost ID/password?