Java static and condition checking

While reading Martin Fowler’s book “Patterns of Enterprise Application Architecture “, found a good way to check input parameters. This is a kind of pre-condition checking in Design By Contract methodology.

class PluginFactory...
	private static Properties props = new Properties();

	static {
		try {
			String propsFile = System.getProperty("plugins");
			props.load(new FileInputStream(propsFile));
		} catch (Exception ex) {
			throw new ExceptionInInitializerError(ex);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s