28 EXPLICIT OBJECT RELEASE
DESCRIPTION
In general, an object may need to deal with external resources such as files, databases and network connections as part of its implementation to provide the services it is designed for. The Explicit Object Release pattern suggests that when such an object is no longer needed, the external resources tied up with the object should be released explicitly, in a timely manner.
The Java programming language provides the following two ways to design the mechanism to release external resources explicitly:
- The finalize() method
- The finally statement
The finalize Method
Some object-oriented programming languages require a programmer to explicitly destroy objects when they are no longer needed. In the Java programming ...
Get Software Architecture Design Patterns in Java now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.