Wednesday, January 18, 2006

 
Refactoring Code

I love to refactor code I've written myself. Finding and correcting mistakes that you made before anyone else spots them is always fun. Especially when you leverage in other people's work nabbed from the open source community. For example, config file used to say:

mailserver = "smtp.blah.com";
adminmail = "blah@blah.com";
debug = true;
datasource = "myDatasource";

And now it says:

chiliBeanFactory = createObject("component","lib.chilibeans.beanfactory").init(".#dirSep#xml-config");

configsysBean = chiliBeanFactory.CreateBean("configsys.xml");

mailserver = configsysBean.getMailServer();
adminmail = configsysBean.getadminmail();
debug = configsysBean.getdebug();
datasource = configsysBean.getdatasource();

The difference is that not only did I move basic config information out of actual code files and into an xml file, I did so without doing a bunch of coding myself. You know, various file actions and the like. Instead I used JRH's wonderful Chilibeans. I got working code in 5 minutes instead of 30.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?