The worlds quickest refactoring

..well, maybe not. But my quickest at the very least occured today. I was using a dojo FilteringTable to show all blueprints in the database, so that they could be sorted on each column properly. Now that I've switched back to the visual component view (the main view) again where you actually create and resize items on the page, I needed a similar view for choosing which blueprint to instantiate (create an infotron) in the component.

I thought that possibly I could just make another blueprint of the logic which hold the Filteringtable itself, and then pass JDA messages back and forth, but I wasn't clear on how to wire things up.

After maybe 30 minutes, I had broken out all the code which created and populated the FilteringTable in a separate blueprint; The logic which defined the columns and column types was passed as a property, as was the css classes for headers and body elements. The actual data in the table was consumed in an input terminal, and when any row is selected, the row (the whole object, skinny legs and all, since we're talking javascript function calls at the bottom of everything here) gets put to an output terminal.

So after just half an hour I had encapsulated the whole logic of using a dojo filteringtable. I also pass as property the DOM node which the table should replace when created.

Then I edited my component manager, so that it created a new instance of the FilteringTableWrapper (which I finally called it - not a very daring name, but that's life) dynamically, by calling __star.addInfotron, where properties and component wiring back to the anager itself was arguments, and as always... it just worked.

I really, really hope I never get used to that feeling. As soon as I can make a generic security and storage microkernal specification with J2EE and PHP implementations, I'll never code anything but js again, promise :)

Comments