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?

  • 1
    Destruct? (need more letters)
    – Deiwin
    Aug 30, 2012 at 14:14
  • 46
    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, 2012 at 14:31
  • 7
    Sadly I can't add an answer anymore since the question was closed (As earcam said: How is this not constructive?), so I will add my answer here. The short, comment-friendly form is this: Use Initialize only if you do not need an antonym! In case you need one select another verb (most of the time there is a more descriptive alternative). For further reference I'm providing my list of antonyms for programmers at GitHub.
    – Max Truxa
    Apr 16, 2015 at 21:56
  • 4
    I found the answers to this very helpful when I had exactly the same question. It should not have been closed.
    – Ian Goldby
    May 13, 2015 at 7:53
  • 3
    I agree ... closing this question is not helpful at all.
    – aurora
    Jan 11, 2016 at 13:06

10 Answers 10


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.

  • 9
    +1 for terminate(). I feel it is generally unambiguous and probably reasonably applicable across use cases. Aug 31, 2012 at 10:32
  • 10
    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, 2012 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, 2013 at 13:45
  • 3
    @Nicki Looks expensive to have to re-install windows at each object destruction...
    – Klaim
    Mar 5, 2013 at 20:43
  • As earcam pointed out: It is set up (which matches tear down) not setup (there is no such verb in the English language).
    – Max Truxa
    Apr 16, 2015 at 18:21

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.

  • 2
    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. Aug 31, 2012 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. Aug 31, 2012 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) Aug 31, 2012 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. Aug 31, 2012 at 19:32

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.



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.

Not finalize()

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().

  • 3
    You make a valid point about finalize() in Java ... but the OP did not indicate anywhere that I saw that the question was specifically dealing with Java, and not any other OO language with "method names" (e.g., C++).
    – EliSko
    Oct 19, 2017 at 20:05
  • In C#, Finalize is used to destruct instances of classes. Nov 6, 2018 at 19:52

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.


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

  • 6
    To my mind, "destroy" is paired with "create".
    – EliSko
    Oct 19, 2017 at 20:08

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.


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.

  • 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. Aug 30, 2012 at 16:09
  • 1
    @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, 2012 at 16:20


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(). )

  • FYI: finalize is reserved in Java. May 27, 2017 at 6:16

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.

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