2D Array - really that hard?

Started by
5 comments, last by ysg 11 years, 1 month ago

OK, I have to play.

Over a decade ago I was working on a project with another developer whose job it was to implement the model for a 2D scatter plot. The scatter plot had the ability to color-by and size-by - pick a data column and you would get a color or size gradient based on the data values. We had settled on 20 color steps and 20 size steps for the plot, and he was perplexed by how to accomplish this. I suggested a 20x20 2D array, each element of which would hold the indices of the points corresponding to that a particular size and color, with the data range divided by 20 to get the bins for each one. Not the most elegant solution, but seemed workable.

We were developing in VB 6 and he was enamored with dictionaries - everything was a dictionary. So, he developed a dictionary that would be accessed by a two element string consisting of the bin locations. In other words instead of the array bins(x,y), he had the dictionary bins["x,y"]. In his code, he would compute the color/size bin numerically, combine these into a string, use this to access the dictionary. OK, whatever.

Put on top of this that his code computed the color and size bin locations in different locations and they might not always occur in the same order - sometimes you got "color,size" and sometimes you got "size,color." It all depended on if the user clicked "color by" or "size by" first. Oh, and he would use "first element 0" based calculations in one area and "first element 1" based calculations in another area.

Now the kicker - the item stored in the dictionary was - wait for it - another dictionary. This one was accessed by breaking up the original string key, doing some non-sensical conversions (not the obivous 20*y+x to get a linearlized array from the 2D array), and then access this dictionary with that new, converted key. Which was converted to a string.

I inherited this code when he left.

Advertisement

By 'inherited' I hope you mean 'replaced within minutes'.

By 'inherited' I hope you mean 'replaced within minutes'.

Excellent observation, but actually "inherited" in this case translates to "deleted and rewrote from scratch." 8^D

Just one more layer of fun. When my colleague left, I was given access to his folders where he stored code - he didn't use any code management system, as if you needed to be told that. I had to navigate by timestamps since his directory structure consisted of :

/old

/older

/new

/newer

/newest

/newer_than_newer

/most_newer

I'm not kidding. <shudder>

By 'inherited' I hope you mean 'replaced within minutes'.

Excellent observation, but actually "inherited" in this case translates to "deleted and rewrote from scratch." 8^D

Just one more layer of fun. When my colleague left, I was given access to his folders where he stored code - he didn't use any code management system, as if you needed to be told that. I had to navigate by timestamps since his directory structure consisted of :

/old

/older

/new

/newer

/newest

/newer_than_newer

/most_newer

I'm not kidding. <shudder>

That's what I encountered when I worked with a team during my undergrad: I had to enlighten them to the wonders of SVN. My most helpful and competent partner on an OS assignment kept all versions of his code in various folders on a thumb drive. We once spent two hours comparing lines on a "fix" he was trying to implement only to find out he hadn't put the latest folder onto the thumb drive.

Your pain, I feel it.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

We once spent two hours comparing lines on a "fix" he was trying to implement only to find out he hadn't put the latest folder onto the thumb drive.

Ah, the classic TDVC - thumb drive version control. Love it.

I haven't even started using version control at work until roughly 3 years ago. It was a pretty small company back then, and we were subcontracted by a different, larger web development agency who's in charge of giving updates to our client. The project was kept in an online SVN repository, and that company basically forced our company to switch from FTP to SVN to do the job. Previously, in the rare case that I had larger projects with remote employees, we often stepped on each others' toes and accidentally erased each others' changes a few times.

New game in progress: Project SeedWorld

My development blog: Electronic Meteor

By 'inherited' I hope you mean 'replaced within minutes'.

Excellent observation, but actually "inherited" in this case translates to "deleted and rewrote from scratch." 8^D

Just one more layer of fun. When my colleague left, I was given access to his folders where he stored code - he didn't use any code management system, as if you needed to be told that. I had to navigate by timestamps since his directory structure consisted of :

/old

/older

/new

/newer

/newest

/newer_than_newer

/most_newer

I'm not kidding. <shudder>

That's not so bad.

Our whole intra is like that (take what you have there and multiply by 100). My team lead (the guy above me), looked at me like I wanted to kill kittens when I proposed that we clean it up and make more consistent structures (to him, this was "logical"). This is the same guy who never heard of the waterfall model and dropped out of the CS program because it was too hard.

My last day is next week.

This topic is closed to new replies.

Advertisement