01.Blogs :
RobMiles  
Programming, gadgets and life as a lecturer in a UK university.

The Evil that is Block Copy

I've just lost around half an hour of work because of the evil of block copy. I'm seriously thinking of setting up a student project to make block copy not work in Visual Studio. Moving code around is fine, but pasting multiple copies should be forbidden. If your lines of code need to be performed more than once, then put them in a method and call the method. Otherwise you'll have the problems that I had.

I copied the text because the action was the same, but with different data. It would have worked fine if I'd changed all the things in the copy, but of course I forgot and left one as per the original. The result was a nastly little bug which took me half an hour to sort out. If I'd not had the block copy command I would not have done this, and so not had the problem.

What do people think?

posted on Thursday, May 26, 2005 6:48 PM by RobMiles

# @ Thursday, May 26, 2005 8:48 PM

I am reminded of the saying that "it is a poor workman who blames his tools." :-) I think in the future some refactoring tools, like the ones in Visual Studio .NET, may provide a better solution. As long as people learn how to use them and avoid the old tools that only look like the easy way to do thing.

AlfredTwo

# @ Thursday, May 26, 2005 9:35 PM

I find it strange to hear that from someone who was such an advocate of block copy once. However, there have been a number of occasions where I've forgotten to change something like a variable name after block copying. It's a minor annoyance though as that sort of copying can be a real time saver.

Pimp_Daddy

# @ Friday, May 27, 2005 12:15 AM

Yup. I agree with Alfred. I don't understand the logic of block copy. Things are much easier by calling a method with an additional parameter to accomdate the slight change of data. Gd software enginnnering practices save time. It's not just a case of formality. Sorry if my comment sounded shallow as I may not understand the full context of your posting.

Bernard

# @ Friday, May 27, 2005 4:14 AM

hrmm there are times that block copying works better for me. but there are times when it doesn't. it all depends on my mood i guess. but compared to just calling methods, block copying can be a real nightmare when it comes to debugging

geraldson

# @ Friday, May 27, 2005 6:57 AM

I have done the same thing a thousand times, and I will do it a thousand times more. Often there is no solution other than being thorough - if you're doing lots of coordinate based stuff with X and Y values (say for example, checking every square adjacent to something) then you often have lots of lines of code with 'x + 1' replaced with 'y + 1' and the same with minus, in all different combinations. It comes out as a big block of code and it is far faster to copy and paste, providing you alter everything correctly. _ The solution is really going to have to be an intelligent GUI. I'm sure it's only a matter of time. When you're doing something in visual studio it should be able to pick up on what you're doing (especially when systematically adding the same thing) and fill it out for you. Who knows though?

Pandilex

# @ Friday, May 27, 2005 8:01 AM

Hmm. Don't remember being an advocate of Block Copy. And I'm not realy blaming my tools as such, I knew the risk I was running wen I used the tool, I just didn't manage the risk very well. I think that Pandilex has this one right, in that an even more intelligent IDE should be able to get some context on what you are doing. If ten lines of code fiddle mostly with five variables, but suddenly mention a sixth one which is also used intensively in another part of code it would be reasonable for the system to suspect that the programmer had got something slightly adrift. Then again, the right solution is always to factor the code into a method, so perhaps I should not think about making block copy easier.

RobMiles


 
03.UPDATE CALENDAR :
<May 2005>
SunMonTueWedThuFriSat
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

05.MY LINKS :

07.Subscriptions :

Subscriptions


© Copyright 2005 Microsoft Corporation. All Rights Reserved.
Terms of Use | Privacy Statement | Code of Conduct | Hosted by MaximumASP for Microsoft
WHO-BAR