The Type Object Pattern
暂无分享,去创建一个
Consider for example a system for tracking the videotapes in a video rental store’s inventory. The system will obviously require a class called “Videotape.” Each instance of Videotape will represent one of the videotapes in the store’s inventory. However, since many of the videotapes are very similar, the Videotape instances will contain a lot of redundant information. For example, all copies of Star Wars are pretty similar: they have the same title, rental price, MPAA 1 rating, etc. This information is different for The Terminator, but all copies of The Terminator have the same data. Thus repeating this information through all copies of Star Wars or all copies of The Terminator is redundant.
[1] Ralph Johnson,et al. design patterns elements of reusable object oriented software , 2019 .
[2] James Martin,et al. Object-oriented methods : a foundation , 1995 .
[3] Ralph Johnson,et al. Type object , 1997 .