17
Last Line Effect Who? Andrey Karpov What He Does? An unusual job Like What? Analyze program code of various applications with the help of static analyzers and write descriptions of errors and defects he finds Nice Job right?

Last line effect

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Last line effect

Last Line EffectWho? Andrey Karpov

What He Does? An unusual jobLike What? Analyze program code of various applications with the help of

static analyzers and write descriptions of errors and defects he

findsNice Job right?

Page 2: Last line effect

How do I know about this?

Page 3: Last line effect

Can I know more about it?

• Do you like to TYPE a similar code again & again while programming?

NO• So What you do at this situation?

COPY & PASTE

Page 4: Last line effect

What’s wrong with this?

• you risk easily forgetting to change something in the pasted lines and thus giving birth to errors.

• What kind of errors? Can you show me some examples?

SURE

Page 5: Last line effect

What’s wrong with this?

Page 6: Last line effect

What’s wrong with this?

Note the line "z += other.y;". The programmer forgot to replace 'y' with 'z' in it

Page 7: Last line effect

What’s wrong with this?

Page 8: Last line effect

What’s wrong with this?

The length of the "THREADS=" string is 8 characters, not 6

Page 9: Last line effect

What’s wrong with this?

Page 10: Last line effect

What’s wrong with this?

The SetW() function should be called at the end

Page 11: Last line effect

What’s wrong with this?

Page 12: Last line effect

What’s wrong with this?

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

Page 13: Last line effect

What’s wrong with this?

Page 14: Last line effect

What’s wrong with this?

The length of the "BITLIST" string is 7, not 3 characters

Page 15: Last line effect

What was his conclusion?

• The probability of making a mistake in the last pasted block of code is 4 times higher than in any other block

• So BE CAREFUL while doing COPY & PASTE

• Make sure to REVIEW it before committing to version control repositories

Page 16: Last line effect

You can read about this more on the following link,

http://www.viva64.com/en/b/0260/

Page 17: Last line effect

Thank You & Have a Great Week End