Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a Java class that handles import and export of data. It started out as a simple

private void export() {
}
private void import() {
}

Of course, I wrote the export first, committed it, and then went on to write the import. But import is a keyword in Java - I can't use that as a function name. So I go back and rename both methods. I usually end up with

private void doExport() {
}
private void doImport() {
}

which is both ugly and feels contrived. What do you think of these names? Got any better suggestions?

Note: I'm asking now, because it's now happened thrice and that keyword is getting quite annoying.

share|improve this question
    
I realize this method is quite subjective. I hope it's not off-topic here. –  configurator Sep 29 '10 at 23:48
    
This might be subjective, but it's still directly programming related, so I'd argue it belongs on StackOverflow and not here. –  Peter Boughton Sep 29 '10 at 23:56
1  
I don't think SO would appreciate this kind of question. –  configurator Sep 30 '10 at 0:01
    
See meta.programmers.stackexchange.com/questions/350/…. You could change your question to match 1, your question might meet 2, I guess it will meet 3; it meets 4, 5 and 6... –  Tom Wijsman Sep 30 '10 at 1:03
add comment

2 Answers

up vote 3 down vote accepted

I would prefer something like this:

private void importData(){}
private void exportData(){}

If you now would use this Class as an API you can do something like this:

dataUtil.importData();

With the CodeCompletion of the IDE, the differences are more visible if this methods wouldn't start the same way.

share|improve this answer
    
I agree, this is much better than doImport/doExport for most cases. Good answer! –  configurator Oct 5 '10 at 23:28
add comment

This is the same problem as with all keywords in programming languages. But the problem is easy, just chose another name.

How about this?

private void dataExport() {
}
private void dataImport() {
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.