Created
September 25, 2011 21:27
-
-
Save philipschwarz/1241175 to your computer and use it in GitHub Desktop.
Separating use from construction - Before
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BusinessObject { | |
public void actionMethod() { | |
// Other things | |
Service myServiceObject = Service.getInstance(); | |
myServiceObject.doService(); | |
// Other things | |
} | |
} | |
class Service { | |
private Service(){ | |
//any needed construction behavior | |
} | |
public static Service getInstance() { | |
return new Service(); | |
} | |
public void doService() { | |
//implementation here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment