- 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.
推薦閱讀
- SQL Server入門經(jīng)典
- Visual Studio 2015 Cookbook(Second Edition)
- MySQL從入門到精通(第3版)
- 大數(shù)據(jù)導(dǎo)論
- 大數(shù)據(jù):規(guī)劃、實(shí)施、運(yùn)維
- 數(shù)據(jù)化網(wǎng)站運(yùn)營(yíng)深度剖析
- R數(shù)據(jù)科學(xué)實(shí)戰(zhàn):工具詳解與案例分析(鮮讀版)
- 云原生數(shù)據(jù)中臺(tái):架構(gòu)、方法論與實(shí)踐
- Python數(shù)據(jù)分析與挖掘?qū)崙?zhàn)(第3版)
- SAS金融數(shù)據(jù)挖掘與建模:系統(tǒng)方法與案例解析
- 貫通SQL Server 2008數(shù)據(jù)庫(kù)系統(tǒng)開(kāi)發(fā)
- Hadoop 3實(shí)戰(zhàn)指南
- MySQL DBA修煉之道
- Internet of Things with Python
- ORACLE 11g權(quán)威指南