April 05
Prof. Ismael H. F. Santos -  ismael@tecgraf.puc-rio.br                                                          2
Example-2a
nExample without DI
npublic class WeatherService {
n  private WeatherDao weatherDao;
n  public Double getHistoricalHigh(Date date) {
n    WeatherData wd = weatherDao.find(date);   .....
n  }
n}
npublic class StaticDataWeatherDaoImpl implements WeatherDaov{
n  public WeatherData find(Date date) { .... }
n}
n
nClient
nWeatherService ws = new WeatherService();
nDouble high = ws.getHistoricalHigh(
nnew GregorianCalendar(2004, 0, 1).getTime());
nSystem.out.println("High was: " + high);
n