Resource cleanup closes the ending of an operation by ensuring acquired files, connections, sockets, and similar resources are handled after success or failure. Treat it as part of the method’s story, not as an afterthought. section 2.5
When reviewing a method, ask:
- Are all acquired resources cleaned up properly, including files, connections, and sockets? section 2.5
- Does failure have an explicit outcome through meaningful exceptions, logs, or fallbacks? section 2.5
- Can the ending communicate a clear success or failure signal without forcing readers to reconstruct the method? section 2.5
Rewrite the story
Choose a long method, identify its plot and recognizable chunks, then extract action- and scene-level methods where they clarify intent. Review the revised ending: confirm that success or failure is clear and that every file, connection, or socket is cleaned up. section 2.5





