7.7 Strategy

To manage the diversity of the operating systems and hosts a Cuis-Smalltalk application is running on, the strategy pattern is handy.

In DrGeo, it is implemented with a hierarchy of DrGPlatform, each one with its own strategy to access resources and preferences in the host: DrGWorkstation to operate on personal computer, DrGDevelopment to operate on developer mode, DrGAndroid and DrGiPad on tablet. The two later ones are not implemented any more as DrGeo is not ported any more to these devices.

Then, in the DrGeoSystem class, it is decided which kind of platform to use, depending on how the system is configured

DrGeoSystem>>beWorkstation
platform := DrGWorkstation new

or

DrGeoSystem>>beDevelopment
" Be like the Cuis environment for DrGeo development "
platform := DrGDevelopment new

The resources are accessed from the DrGeoSystem public class protocol without knowing which platform is used underneath

DrGeoSystem class>>iconsPath
^ platform iconsPath

It depends on the selected platform, only known by DrGeoSystem:

DrGPlatform>>iconsPath
^ self resourcesPath / 'icons'
DrGWorkstation>>iconsPath
^ self resourcesPath / 'graphics' / 'iconsSVG'