Still, thing weren't perfect. The WeatherEngine uses DataEngines itself and chains them together. So when you ask for weather for a given location, WeatherEngine actually loads a second DataEngine that talks to that specific service. This makes each service nicely compartmentalized and plugin based without a whole lot of duplication of effort.
Chaining the DataEngines was not exactly a straight-forward exercise back then, but Shawn muddled through and the DataEngine API improved alongside those efforts. It did, however, work.
Today on IRC while discussing things like being able to easily add new WeatherEngine plugins, I realized that by using DataEngine for the plugins we should also be able to get scripting and package support ... for free!
Well, almost for free. You see, due to be written "back in the day" there was a lot of code in WeatherEngine for managing its own plugins. Something that today's Plasma infrastructure pretty much obsoleted. I added just one convenience function to DataEngineManager, which I could have just put into WeatherEngine, really. That would have lead to code duplication eventually, though, so into the library it went.
I then put about taking out the custom code in WeatherEngine and replacing it with the libplasma equivalents. The end result was a patch that weighed in at a net loss of 128 lines. Yep, the WeatherEngine actually got smaller and simpler. In exchange for the lost complexity and half an hour of my time, WeatherEngine instantly gained the following functionality in return:
- Support for Plasma::Package'd plugins
- JavaScript, Python and Ruby scripting support
- The ability to list and explore plugins with `plasmaengineexplorer --app weatherengine`
- A very easy way to hook into Get Hot New Stuff / DXS

Remember, while this was initially all designed for the Weather widget, it can be used by anybody who cares to find out weather information. Currently only the Weather and LCD Weather Station widgets do use it, but with libplasma in kdelibs the doors are wide open. Did I mention that neither widget required any changes to their code, not even a recompile, to take advantage of the new and improved engine? =)
This made us all very, very happy. Tears of joy and ticker tape parades through the streets of #plasma type happy.
Code less. Create more. Oh, wait, someone's already taken that slogan, haven't they? ;)

3 comments:
Awesome. The efforts and work spent on Plasma are clearly visible now that everything is (almost) in place.
Congrats :)
Nice screenshot.. though not even vancouver is that warm right now!
I had a job where I worked on an application. No surprise there, I reduced the code base by 30%, kept all the features and added new ones. And let me tell you, it ran better and look less memory.
30%... I don't know if that speaks about me or how bad the previous programmers were. I'll split it and still be happy.
It is a fantastic feeling!
Post a Comment