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

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.

主站蜘蛛池模板: 江陵县| 南漳县| 东辽县| 鄯善县| 高碑店市| 丁青县| 什邡市| 巫溪县| 彭州市| 宁都县| 株洲市| 兴隆县| 吉安县| 淳化县| 绥江县| 嘉义县| 铅山县| 博湖县| 左权县| 银川市| 荣成市| 客服| 霞浦县| 富裕县| 增城市| 甘德县| 平谷区| 灵璧县| 建始县| 旬邑县| 定日县| 全椒县| 盐边县| 新津县| 会同县| 曲靖市| 遵义市| 浦县| 安乡县| 武宁县| 鄂托克旗|