What is the opposite of initialize (or init)? [closed]

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?

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

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.

4

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.

close()

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

2

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.

1

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.

2

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

1

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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật