• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# 2D Array - really that hard?

6 replies to this topic

### #1kirkd  Members

Posted 26 February 2013 - 11:00 AM

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.

### #2Kylotan  Moderators

Posted 26 February 2013 - 05:55 PM

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

### #3kirkd  Members

Posted 27 February 2013 - 11:16 AM

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

I'm not kidding.  <shudder>

### #4BCullis  Members

Posted 27 February 2013 - 12:00 PM

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

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.

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

### #5kirkd  Members

Posted 27 February 2013 - 12:16 PM

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.

### #6CC Ricers  Members

Posted 27 February 2013 - 02:14 PM

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

### #7ysg  Members

Posted 01 March 2013 - 02:22 PM

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

I'm not kidding.  <shudder>