{"id":23,"date":"2009-04-11T05:05:35","date_gmt":"2009-04-11T12:05:35","guid":{"rendered":"http:\/\/stupidzombie.com\/blog\/?p=23"},"modified":"2009-04-11T05:05:35","modified_gmt":"2009-04-11T12:05:35","slug":"refactoring-refactoring","status":"publish","type":"post","link":"http:\/\/stupidzombie.com\/blog\/2009\/04\/11\/refactoring-refactoring\/","title":{"rendered":"Refactoring, refactoring&#8230;"},"content":{"rendered":"<p>Yep. Old code was &#8230; 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:<\/p>\n<pre lang=\"Java\">\r\nimport java.lang.management.ManagementFactory;\r\nimport java.util.Set;\r\nimport java.util.TreeSet;\r\nimport java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\nimport java.util.prefs.Preferences;\r\nimport java.util.ResourceBundle;\r\n\r\nimport javax.management.MBeanServer;\r\nimport javax.management.ObjectName;\r\n\r\n\/**\r\n * Factory class to return the proper Ping instance\r\n * @author undead@stupidzombie.com\r\n *\/\r\npublic final class PingFactory {\r\n\t\r\n\t\/**\r\n\t * Supported ping types\r\n\t *\/\r\n\tpublic static enum PingTypes {\r\n\t\t\r\n\t\tUNKNOWN(\"\", \"\"), \r\n\t\tTO2BLOGS(\"To2Blogs\", \"PINGBLOG_TO2BLOGS_UNIQUEID\"), \r\n\t\tBLOGALAXIA(\"Blogalaxia\", \"PINGBLOG_BLOGALAXIA_UNIQUEID\"), \r\n\t\tVENEBLOGS(\"Venblogs\", \"\"), \r\n\t\tWEBLOGS(\"Weblogs\", \"\"), \r\n\t\tTECHNORATI(\"Technorati\", \"\"), \r\n\t\tBITACORASCOM(\"Bitacoras.com\", \"\"), \r\n\t\tPINGOMATIC(\"PingOMatic\", \"\");\r\n\t\t\r\n\t\tpublic String desc;\r\n\t\tpublic String id;\r\n\t\tprivate PingTypes(final String aDesc, final String aId) {\r\n\t\t\tdesc = aDesc;\r\n\t\t\tid = aId;\r\n\t\t}\r\n\t}\r\n\t\r\n\tprivate static PingFactory factory;\r\n       \/\/ Rest of the code ommited :)\r\n<\/pre>\n<p>it is amazing how simple Enumerations simplified the code on this class. Now working on the ping controller, that section is long overdue \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yep. Old code was &#8230; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,6,14],"tags":[15,62,16,66],"_links":{"self":[{"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/posts\/23"}],"collection":[{"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":2,"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":25,"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions\/25"}],"wp:attachment":[{"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/stupidzombie.com\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}