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

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.

主站蜘蛛池模板: 通渭县| 沙湾县| 宁河县| 盱眙县| 广丰县| 朝阳区| 西畴县| 林芝县| 保靖县| 奉贤区| 容城县| 奎屯市| 潞西市| 潼南县| 辉县市| 灌南县| 琼中| 海丰县| 突泉县| 陆良县| 浦城县| 岫岩| 浦北县| 罗田县| 庆安县| 徐闻县| 长春市| 拉萨市| 长春市| 中牟县| 前郭尔| 太仆寺旗| 石阡县| 阿勒泰市| 石城县| 宝兴县| 松阳县| 金沙县| 小金县| 精河县| 大姚县|