dimanche 22 mars 2015

How much data from a web service should I expose in a library?


I'm working on a personal project, a library that can access the weather forecasts and other weather related data from it.


However, a lot of the returned data is sometimes quite redundant or simply doesn't make sense to have certain data within that particular XML element etc. Consider this XML data I get from the service, which contains the hourly forecast:



<hour>20</hour>
<hour_padded>20</hour_padded>
<min>00</min>
<min_unpadded>0</min_unpadded>
<sec>0</sec>
<year>2015</year>
<mon>3</mon>
<mon_padded>03</mon_padded>
<mon_abbrev>Mar</mon_abbrev>
<mday>21</mday>
<mday_padded>21</mday_padded>
<yday>79</yday>
<isdst>0</isdst>
<epoch>1426968000</epoch>
<pretty>8:00 PM GMT on March 21, 2015</pretty>
<civil>8:00 PM</civil>
<month_name>March</month_name>
<month_name_abbrev>Mar</month_name_abbrev>
<weekday_name>Saturday</weekday_name>
<weekday_name_night>Saturday Night</weekday_name_night>
<weekday_name_abbrev>Sat</weekday_name_abbrev>
<weekday_name_unlang>Saturday</weekday_name_unlang>
<weekday_name_night_unlang>Saturday Night</weekday_name_night_unlang>
<ampm>PM</ampm>


As you can see there is a lot of data that you probably don't need, because you can calculate/convert the time/date information into a simple DateTime etc. Another useless series of fields is the "padded" ones. There a lot of other examples of this redundancy with other types of weather data as well.


So how should I approach this, have literally every field in the XML available to the user of the library, or just stick to having only the parts that make sense available to the user? I'm leaning towards only the parts that make sense, but wanted to ask the opinion of others.





Aucun commentaire:

Enregistrer un commentaire