私有类数据模式(Private class data pattern)

来源:互联网 发布:小七网络查询成绩 编辑:程序博客网 时间:2024/05/16 09:38

The private class data design pattern seeks to reduce exposure of attributes by limiting their visibility. It reduces the number of class attributes by encapsulating them in single Data object. It allows the class designer to remove write privilege of attributes that are intended to be set only during construction, even from methods of the target class

这种私有的数据类程序设计模式的目的,通过控制一些属性的可见性,来减少暴露在外的属性的数量。由于把这些类的属性包装到一个数据对象中,可见的类的属性就减少了。类的属性的赋值就只能在实例化时完成,目标类的方法也不能对这些属性的值进行操作。