How to improve my first ofxaddon project?

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.

How to improve my project? Is there any good way?

Hi @ryohajika, here’s a few thoughts while looking it over:

  1. 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()

  2. It’d probably be better to use ofLogVerbose() for your “Weather Data Updated!” message

  3. 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.

  1. It looks like updateIntervalSeconds isn’t actually used, though? It’d definitely be good to take that out, as that will confuse users.

Thank you for your advise, @admsyn!

I’ll update sources soon!

That’s right. Now, I’m looking for any good way to make request to the weather API server automatically and periodically. That’s why I leave the word in the source.
Do you have any idea?