Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


2D Array - really that hard?

  • You cannot reply to this topic
6 replies to this topic

#1 kirkd   Members   -  Reputation: 505

Like
3Likes
Like

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.

 



Sponsor:

#2 Kylotan   Moderators   -  Reputation: 3338

Like
2Likes
Like

Posted 26 February 2013 - 05:55 PM

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



#3 kirkd   Members   -  Reputation: 505

Like
1Likes
Like

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

/newer

/newest

/newer_than_newer

/most_newer

 

I'm not kidding.  <shudder>



#4 BCullis   Crossbones+   -  Reputation: 1813

Like
2Likes
Like

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

/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
DeviantArt :: Because right-brain needs love too

#5 kirkd   Members   -  Reputation: 505

Like
0Likes
Like

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.



#6 CC Ricers   Members   -  Reputation: 802

Like
0Likes
Like

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.


My development blog: Electronic Meteor

#7 ysg   Members   -  Reputation: 192

Like
0Likes
Like

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

/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.


Edited by ysg, 01 March 2013 - 02:23 PM.






PARTNERS