- Hands-On Design Patterns with Java
- Dr. Edward Lavieri
- 171字
- 2021-06-24 14:58:00
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.
- 云數(shù)據(jù)中心基礎(chǔ)
- Python絕技:運(yùn)用Python成為頂級數(shù)據(jù)工程師
- 輕松學(xué)大數(shù)據(jù)挖掘:算法、場景與數(shù)據(jù)產(chǎn)品
- Spark大數(shù)據(jù)分析實(shí)戰(zhàn)
- PySpark大數(shù)據(jù)分析與應(yīng)用
- Live Longer with AI
- 深度剖析Hadoop HDFS
- 大數(shù)據(jù)營銷:如何讓營銷更具吸引力
- 中國數(shù)字流域
- Flutter Projects
- Power BI智能數(shù)據(jù)分析與可視化從入門到精通
- 智慧城市中的大數(shù)據(jù)分析技術(shù)
- 算法設(shè)計(jì)與分析
- 算力經(jīng)濟(jì):從超級計(jì)算到云計(jì)算
- 從Lucene到Elasticsearch:全文檢索實(shí)戰(zhàn)