- Hands-On Design Patterns with Java
- Dr. Edward Lavieri
- 101字
- 2021-06-24 14:58:00
Encapsulating to protect
Earlier in this chapter, we defined encapsulation as the hidden nature of an object's data. Granting access to an object's data via its own accessors and mutators is a great approach to data protection.
We use encapsulation as an approach to data protection in OOP. Encapsulating too much data into a class is an anti-pattern—something that should be avoided. As with the create concise objects approach, we should identify what data all copies of an object have in common and only encapsulate those data elements. Other data might be better suited for an ancillary class.
推薦閱讀
- 企業數字化創新引擎:企業級PaaS平臺HZERO
- Hands-On Machine Learning with Microsoft Excel 2019
- Architects of Intelligence
- 使用GitOps實現Kubernetes的持續部署:模式、流程及工具
- Spark大數據分析實戰
- InfluxDB原理與實戰
- 文本數據挖掘:基于R語言
- Enterprise Integration with WSO2 ESB
- 數據驅動設計:A/B測試提升用戶體驗
- 數據庫程序員面試筆試真題庫
- 數據庫原理與應用(Oracle版)
- 數據挖掘原理與SPSS Clementine應用寶典
- Oracle RAC日記
- 跨領域信息交換方法與技術(第二版)
- 數據修復技術與典型實例實戰詳解(第2版)