Design for PHP Weather 2
Brought to you by:
iridium
|
From: Martin G. <gim...@gi...> - 2002-03-15 18:39:38
|
Hi again
I've thought some more about how we could structure PHP Weather 2. The
design that's currently in CVS isn't final - it's actually my first
attempt at using objects in a program. I've learned Java since, and
with that a lot of OO.
My plan is to separate the METAR-parsing logic from the output. So we
should have a class phpweather that handles the parsing of the METAR
and uses the database-layer to cache it.
Then we should have several modules (two so far) which talk to the
phpweather object and retrieves the parsed METAR from it. They can
also obtain things like the ICAO and location from the class
phpweather (which can find this information in the database).
The module should work together with a locale to produce the output.
If it doesn't need any localization information, then the locale can
be left out.
So you would probably do something like this:
$weather =3D new phpweather('EKYT');
$locale =3D new pw_locale_en();
$text =3D new pw_module_text($weather, $locale,
array('mark_begin' =3D> '<i>',
'mark_end' =3D> '</i>');
$icon =3D new pw_module_icon($weather);
echo $text->get_output();
echo '<img src=3D"' . $icon->get_output() . '">';
Does this kind of separation make sense?
We would of course have to think about how we are going to let the
locales customize the output of the modules...
=2D-=20
Martin Geisler My GnuPG Key: 0xF7F6B57B
See my homepage at http://www.gimpster.com/ for:
PHP Weather =3D> Shows the current weather on your webpage.
PHP Shell =3D> A telnet-connection (almost :-) in a PHP page.
|