官术网_书友最值得收藏!

Creating concise objects

Objects are at the core of OOP. This principle aims to remind software designers and developers to isolate objects to a specific model. Using our Bicycle class as an example, we would create Bicycle objects that contained the appropriate attributes and behaviors. The bicycle attributes used in this chapter were gears, cost, weight, and color. We created accessors and mutators for each of those attributes. We also created a method that echoed the object's attributes to the output console. No behaviors were added to the Bicycle object, but we could have included behaviors such as upgrade()

What we did not include in the Bicycle class were attributes and behaviors that were ancillary to the Bicycle object. Examples of these include the owner's address, vacation details, and more. While the data might be somewhat related to a specific Bicycle, it is not part of a real-world bicycle that we need to model.

Adhering to this principle helps ensure our code is concise, easy to maintain, and portable.

主站蜘蛛池模板: 天台县| 泽州县| 视频| 门头沟区| 红河县| 微山县| 田阳县| 呼图壁县| 昆山市| 博乐市| 锡林浩特市| 崇阳县| 崇左市| 梧州市| 崇左市| 灵山县| 烟台市| 莲花县| 阿拉善左旗| 探索| 宁城县| 临潭县| 赤水市| 财经| 宕昌县| 老河口市| 如皋市| 皋兰县| 赤壁市| 台中市| 宁明县| 苏尼特左旗| 灵台县| 茂名市| 平乡县| 栖霞市| 韩城市| 牙克石市| 黎城县| 涟水县| 永福县|