Re: ctrl-c ctril-v
Jim Janney wrote:
Lew writes:
Jim Janney wrote:
This is a good thing. Programmers should not copy/paste on a regular
basis.
Ridiculous assertion.
I wan't entirely serious when I wrote that. However...
Any time I find myself faced with a lot of similar code, I do start
looking for ways to abstract out the similarities, in whatever language
I happen to be working in. Java is particularly rich in ways to
accomplish this. And for really trivial boilerplate code, any good
programming editor should provide ways to generate that that are both
more flexible and less error-prone than simple copy/paste. Again,
Eclipse is particularly rich in ways to accomplish this.
I stand by my ridiculous assertion :-)
It's too broad.
Let's say I have a method name 'loadResourceFromBlarg()' and I'm programming with
Eclipse or NetBeans or one of those editors. Now I could use Ctrl-space to get code
completion, but if there are a number of 'loadResourceFromXxx()' methods, the completion
list might take time. If there are many calls to the method of choice, I'll likely copy the
method name once into the clipboard and repeatedly paste it.
Let's say I'm importing static a bunch of members from a utility class.
import static junit.framework.Assert.assertEquals
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNotSame;
import static junit.framework.Assert.assertTrue;
It's much faster to copy "import static junit.framework.Assert.assert", repeatedly paste it
and just type the part that varies.
This type of thing comes up a *lot*, so I copy and paste on a regular and frequent
basis. This has nothing to do with the refactoring of which you spoke.
You're assertion was ridiculous because it banned legitimate uses of copy-paste.
--
Lew