24h-payday

Refactoring, refactoring…

Yep. Old code was … old, and kind of ugly. Okay, just plain ugly. So refactoring was in order, like on the Ping Factory class which looks much cleaner now:

import java.lang.management.ManagementFactory;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import java.util.ResourceBundle;

import javax.management.MBeanServer;
import javax.management.ObjectName;

/**
 * Factory class to return the proper Ping instance
 * @author undead@stupidzombie.com
 */
public final class PingFactory {
	
	/**
	 * Supported ping types
	 */
	public static enum PingTypes {
		
		UNKNOWN("", ""), 
		TO2BLOGS("To2Blogs", "PINGBLOG_TO2BLOGS_UNIQUEID"), 
		BLOGALAXIA("Blogalaxia", "PINGBLOG_BLOGALAXIA_UNIQUEID"), 
		VENEBLOGS("Venblogs", ""), 
		WEBLOGS("Weblogs", ""), 
		TECHNORATI("Technorati", ""), 
		BITACORASCOM("Bitacoras.com", ""), 
		PINGOMATIC("PingOMatic", "");
		
		public String desc;
		public String id;
		private PingTypes(final String aDesc, final String aId) {
			desc = aDesc;
			id = aId;
		}
	}
	
	private static PingFactory factory;
       // Rest of the code ommited :)

it is amazing how simple Enumerations simplified the code on this class. Now working on the ping controller, that section is long overdue 🙂

Tags: , , ,

One Response to “Refactoring, refactoring…”

  1. Valora en Bitacoras.com: Yep. Old code was ? old, and kind of ugly. Okay, just plain ugly. So refactoring was in order, like on the Ping Factory class which looks much cleaner now: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 …..