Let us introduce the concept of the interface using an example. Suppose that a class needs to be designed with the task of providing weather data for a crop simulation scenario. Weather data can be provided in different ways. Some authors [LKN02] have designed their classes to obtain weather data from a network of real-time weather stations. Others [HWH01] obtain weather data from text files saved locally in the system. It is desirable to design a system flexible enough to provide weather data from several sources. The fact that weather data could be provided in different ways does not affect the logic used to handle these data for calculating photosynthesis processes or water movement in soil. The scientific equations used to calculate photosynthesis will deliver the same results regardless of the source used to obtain the data: Be they read from text files, from a database management system, or obtained directly from an on-line weather station.

Most of the existing systems are designed to use one single source of data. The IBSNAT group has selected to develop a special format of text files to store the weather data [HWH01]. This way of forcing the system to a very specific way of obtaining weather data, limits other valuable sources of weather data to be used such as the ones provided by the on-line weather stations or other important sources.

As previously mentioned, the scientific calculations are not affected by the way weather data are obtained. Therefore, it will be beneficial to express the weather data used in a general way, independently of the particular data source. The object Weather should be designed in such a way that it would provide the data regardless of the specific source used. This object should only logically show the kind of data needed and ignore any particular way of obtaining the weather data. An object that plays this role is called an interface.

[BRJ99] defines an interface as "a collection of operations that are used to specify a service of a class or a component." [Szy99] defines an interface as

"a contract between a client of the interface and a provider of an implementation of the interface." Figure 3-4 shows the UML symbols for an interface.


^getSo!arRadiation() : Double ^getAverageTemperaturef) : Double ^getRainfall() : Double ^getTemperaturefvlinfJ : Double ^getTemperaturemaxQ : Double ^getPARf) ; Double ^getPotentialETf) : Double

0 0

Post a comment