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.

The term will be used as a method name. The method is called when a part of the user interface is hidden (or removed), and it is used to reset values to default and dispose objects that will not be used any more.

Possible names are: release, remove, dispose, clear etc.

Which do you think is the most appropriate?

share|improve this question

closed as not constructive by Robert Harvey, gnat, Walter, Matthieu, Aaronaught Sep 1 '12 at 2:08

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Destruct? (need more letters) –  Deiwin Aug 30 '12 at 14:14
    
also free (especially with memory), deinitialize/deinit –  Ambroz Bizjak Aug 30 '12 at 14:14
    
I vote for rez and derez. –  Izkata Aug 30 '12 at 21:03
    
Can't see how this is not constructive, a quick scan of the answers below shows many developers don't quite get antonyms. IMO method names are very important and "initialize" has no clear antonym, yet is a common and useful term. –  earcam Dec 31 '12 at 14:31

10 Answers 10

I typically go with either Finalize, Destroy, or Terminate depending on what the objects function is.

For the case you describe, Finalize is what I would go with based on my scheme.

share|improve this answer
    
Unfortunately, 'Finalize' could be either a synonym or an antonym of 'Initialize', so I think that it would be a poor choice in general. 'Destroy' and 'Terminate' are contenders, however. See m-w.com/dictionary/finalize for definition saying "to put in final or finished form". I've even seen it used this way in code. I.e., finalizing an object is the last step in its initialization. In contrast, Java's Object class has a finalize() method indicating no more references to the object. –  Ben Hocking Aug 31 '12 at 10:30
    
@BenHocking I think you are taking the "to put in final or finished form" the wrong way. To me, this means that you are done with the object and it's time to clean up / reset all the properties. This is what OP is saying he wants to do. So I think that definition proves my case. –  Brian Dishaw Aug 31 '12 at 16:52
    
Also, any feedback on why the downvote? (I'm assuming it was not @BenHocking since he did not indicate he was the downvoter) –  Brian Dishaw Aug 31 '12 at 16:55
    
a) You're right that I did not down vote. Your suggestion is reasonable and I think this discussion is useful. b) I've seen finalize() used in exactly the sense I indicated. For example, in a class calculating Delauney triangularization, after all of the points were added, finalize() was called to do some additional calculation before results could be used from it. In that case, it indicated that the object was no longer open for modification, but it was still available for use, i.e., to get the results of the triangularization. –  Ben Hocking Aug 31 '12 at 19:32

I use :

  • initialize()
  • terminate()

I find it the more appropriate:

  • it's hard to not see it in code, because it's both long words (I don't use init)
  • it's correct english (AFAIK)
  • in my head, terminate avoids ambiguity. It doesn't match begin (which matches end), start (which matches stop), create (which matches destroy), setup (which matches unset), load (which matches unload) etc.

Some people could find it a question of taste though.

share|improve this answer
3  
+1 for terminate(). I feel it is generally unambiguous and probably reasonably applicable across use cases. –  Ben Hocking Aug 31 '12 at 10:32
2  
I'm in complete agreement with "terminate" all other suggestions are for words with exact, well-known antonyms; destroy (create), tearDown (setUp), close (open), release (acquire), etc. Surprising how many developers fail to see this. –  earcam Dec 31 '12 at 14:26
    
Defenestrate. That's what I do with objects when I'm done with them. (But Terminate would be my second choice.) –  Nicki Mar 5 '13 at 13:45
1  
@Nicki Looks expensive to have to re-install windows at each object destruction... –  Klaim Mar 5 '13 at 20:43

I quite like 'destroy'. Couldn't be clearer unless you're writing a video game or something.

share|improve this answer

and it is used to reset values to default and dispose objects that will not be used any more.

reset seems like a good term if you're resetting the object to defaults. reinitialize could also be appropriate if the use of this object is similar to what initialize does. It sounds like this method will dispose other objects, not the one that's receiving the message, in which case either of the above should be fine. If you're really doing the opposite of init and preparing the receiver to be destroyed, dispose would be a good choice.

share|improve this answer

I like release for a method that disposes of objects and other resources (e.g. as preparation for destruction). I would choose reset for a method that resets values to default.

If the "default" state doesn't require any resources, then reset may be able to call release to perform that part of its operations.

share|improve this answer

My first thought was tear down, but that is used in many testing frameworks. Finalize and dispose have similar problems. Reset, or clean up both seem like good choices. Reinitialize makes it clear it goes back to the initialized state, which would be good if the state you go back to is the initial state.

Just make sure your term isn't overloaded in your current context.

share|improve this answer
    
I don’t see how this is a problem in itself. Granted, Finalize and Dispose are out in .NET code. Other than that, I don’t see a problem with reusing established names. –  Konrad Rudolph Aug 30 '12 at 16:09
    
@KonradRudolph Reusing an established name is fine, IF the concepts align very well. None of the terms I listed align that well with what I understand him to be describing. So it would be more confusing since you would see the term think, I know what that does, and be wrong. –  Sign Aug 30 '12 at 16:20

http://www.wordhippo.com/what-is/the-opposite-of/initialize.html

I would go with finalize. However I think it is a little bit dependent the exact use case: e.g. If you use it mainly to to release resources, close connections, files then release would be more meaningful.

If you are looking for a notion for general use, or standardize, I would choose some less meaningful, something with no special meaning like release, or remove.

The concept of init vs (whatever) is similar to (constructor vs destructor), or in java finalize.

(Note: If the language has the concept construct and destruct objects, its little or no need to use init(). )

share|improve this answer

No-one has proposed close() yet. Java 7 has a new "try with resources" feature. A class that gets cleaned up automatically has to implement java.lang.AutoCloseable which has a single close() method. shutdown() or cleanup() might be good too. finalize() means something specific to the garbage collector in Java, and the way it works is a little weird. I would stay away from finalize() unless you want exactly what Java does with finalize().

share|improve this answer

If the object the method is being called on will cease to be used, I would just use the standard destructor. That doesn't sound like the case, though, so rather than getting too generic, a better name is probably something like hide() if the object itself is being hidden or hideUserInterfacePart() if composed objects are being hidden.

share|improve this answer

I'd say it depends on if the action is optional or required (without leaking resources), and if the language supports constructors/destructors. For optional cases I use:

  • clear
  • reset
  • hide (in UI context)

In other cases where the opposite action is required (in languages without constructors/destructors, or when the destructor doesn't release the resource), I use:

  • init - fini
  • initialize - deinitialize
  • create - destroy

In your case I think I would prefer hide. It can still release memory/resources if it wants to - the important thing is that it is optional, i.e. that the destructor would take care of it if you didn't.

share|improve this answer

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