ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Copy/pasting code and the last line effect

<< < (2/3) > >>

TaoPhoenix:
Happened with me many times. ...
I think the mind really gets 'tired' of repeated... work and starts registering 'Oh come on, it is done' before the last line ends.  :)
-anandcoral (December 09, 2015, 02:01 AM)
--- End quote ---

And it's not just programming, I'll expand it to tedious anything. So in the physical world besides if there's muscle fatigue, you risk injuries from getting sloppy on the last "thing to do".

And just at the end of a big project, when you're checking little stuff, all over the map, even if it's not the same thing, that last couple of things are the ones where an error creeps in.

Heh and it happens in Chess! "Hurry up and resign already I've won... oh $hit ... I just dropped a piece and now I'm about to lose!!"

Renegade:
Heh. Guilty here as well.

MilesAhead:
Whatever it was must have happened to the maintainer of the page since it does not respond.  :D

Edit:  actually I get a server not found but you know what I mean.  :)

hamradio:
Multi Theft Auto

class CWaterPolySAInterface
{
public:
    WORD m_wVertexIDs[3];
};
CWaterPoly* CWaterManagerSA::CreateQuad (....)
{
  ....
  pInterface->m_wVertexIDs [ 0 ] = pV1->GetID ();
  pInterface->m_wVertexIDs [ 1 ] = pV2->GetID ();
  pInterface->m_wVertexIDs [ 2 ] = pV3->GetID ();
  pInterface->m_wVertexIDs [ 3 ] = pV4->GetID ();
  ....
}

The last line was pasted mechanically and is redundant. There are only 3 items in the array.

--- End quote ---

I noticed the author of that article is actually wrong about the above one. Because it appears the array starts at 0 therefore that one is absolutely correct because it has 4 items in the way 0, 1, 2 and 3. ;)

mouser:
actually there is a bigger bug here, though it's hard to be sure exactly what the author intended.

First things first, this looks like c++ code.

my guess is that the most likely bug is the declaration WORD m_wVertexIDs[3] should probably be WORD m_wVertexIDs[4];
creating a 4 element array(vector), indexed from 0 to 3, making the lines in the function correct.  if so this is NOT an example of a last line effect, but a deadly c++ style error of declaring an array too small (which may not be flagged as an error).

It's certainly true that the Multi Theft Auto code example is incorrectly diagnosed -- that last line is not "redundant", it is an error (given the earlier declaration) -- one that would be caught in some languages or cause unpredictable memory problems in others.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version