A Factory
Probably the most frequently used pattern. In your real life, you use it very often.
Imagine that you are buying a PC for your office. Usually you do not shop around yourself, but there is a purchase office which takes care of bids, best prices, and also takes care that all PC’s bought are compatible with each other.
But in software, you have seen this…
hbook1_ (101,”calibration factor 1”, 128, 0., 200., 0.);
hbook1_ (102,”calibration factor 2”, 128, 0., 200., 0.);
hbook1_ (103,”calibration factor 3”, 128, 0., 200., 0.);
What you do here is that you make it explicit that you are dealing with Hbook histograms. If you would want to change the type of histogramming package to, say, Root histograms, you would need to change all your code and implement the new calls for Root histograms.