Pelicans Are Evil

09 May, 2008
 

Refactoring is fun!

My uber lite mvc framework which I use to develop the refresh retreat registration application is going though a moderate refactoring that includes htmlhelpers, collections & a few other bits and peices. I'm actually enjoying the entire process. Using my friend regexp, I'm hardly making any actual coding changes by hand. The hardest part of the process is how to refactor.

I struggled with a few things during the refactor but I put my brain into oo mode and pulled out some semantic (i think) methods for handling the most basic things. Take for example select, radio & checkbox groups. Each requires a list (value/label) item. My first thought was just to use a simple array, but I caught myself on how to use the array (associative arrays, multi-dimentional with specific associative key's to define the value/label.

I almost commited to the array idea, before I remembered my friend collections! So i quickly whipped up 3 new classes, Collections, ListCollection & ListItem. By storing the list of data in a standardised collection I can easily swap between radio groups, selects or checkboxes just by changing the primary method.. Ahh I love inheritance!

The only problem I still have is thats a php4 framework (it was all that was available on the server at the time of me writing the framework). It's a shame to jump back into php4 land after using languages like c#, php5 (it's oo isn't the best but it's leaps and bounds over php4), and actionscript 3. Oh well!

Anyway I've still got more refactoring to do and im looking forward to it.

Till next time!
 
Comments: Post a Comment



Links to this post:

Create a Link



<< Home