Since the 0.1 release of Maps and Semantic Maps, I’ve gotten quite some feedback on what features are in demand and what could be improved. Although I’ve not gotten any specific feedback on the extensions source code itself, I decided that refactoring it to get it as high quality as possible was probably the most important thing in the 0.2 release, since this would facilitate adding functionality and making changes to the existing features. The last few days I had some great fun with the refactoring.
I started off with the form inputs in Semantic Maps. I changed the SMFormInput class, which gets inherited by the mapping service specific classes, by refactoring a whole bunch of common code up from the specific classes. I also went for a more OOP approach, and at some point got stuck cause I could not make static (shared) methods abstract (virtual/must-inherit). After debating this problem with Yaron, and a bunch of people on multiple programming forums, I decided to use the factory model and create instances of the classes instead of just calling static methods. After removing all static stuff from the classes, I added some abstract methods, that get called by formInputHTML(), which is now in the base class, and cannot be changed in the child’s, since it’s final. These abstract functions then get ‘filled up’ in the child classes and contain the service specific code.
I finished doing this yesterday, and am doing a very similar thing with the map classes in Maps now. The approach is basically identical, except for a change I made in how the map properties are handled (weakly typed instead of specificity defined class fields). This work is going hand in hand with another rafactoring to-do, which is the cleaning up of the Yahoo! Maps and Google Maps code in maps. In 0.1 a bunch of JS gets echo’d, and all the logic is done in PHP, which is a bad approach IMHO. I’m changing this to having one JS function to create a map, and just echo’ing the call to it with the correct parameters, and let the function do all the logic.
I expect the later do be done today, and when it is I’m going to add the centre parameter, which has been missing so far in Maps.