I’ve created my first ofxaddon project “ofxYahooWeather”.
In this add-on, using Poco XML parser in order to parse xml data which can get from Yahoo! weather API.
However, because I haven’t get used to use such a high level functions, the project is incomplete and is not clean.
Also, I’d like to add a function that enables the class to update data automatically and periodically.
Hi @ryohajika, here’s a few thoughts while looking it over:
You’re using update() as the function which makes the request to the server. This makes sense, but usually openFrameworks reserves update() for functions which are supposed to be called very frequently. In my opinion, it’d make more sense to call that function refresh()
It’d probably be better to use ofLogVerbose() for your “Weather Data Updated!” message
Internally, you can clean up the different versions of your setup() function by taking advantage of C++'s default arguments. So, you could have just one setup() function, declared in the header like this:
void setup(unsigned int targetWOEID, char temperatureUnit = 'c', unsigned int updateIntervalSeconds = 60);
and then you’d only need to keep one setup() in your .cpp file (the one that has all 3 arguments). Then, if the user just calls weather.setup(15015370), it will still call the version with 3 arguments, but temperatureUnit and updateIntervalSeconds will automatically be 'c' and 60 by default.
It looks like updateIntervalSeconds isn’t actually used, though? It’d definitely be good to take that out, as that will confuse users.