public abstract class Goo implements Gooable { protected abstract void doSomethingThatRequiresSetup(); public void doSomething() { setUp(); doSomethingThatRequiresSetup(); tearDown(); } public void setUp() { ... initialize network connections and blah blah blah } public void tearDown() { ... close network connections and any open files } }