准备OCJP的过程中,屡屡封装良好,松耦合,高聚合提到这三个概念...我暂时没有找到一个定义,自己粗浅地理解如下:
麻烦哪位高手,能否给补充一个定义?谢谢!well encapsulation
1)成员变量、方法private
2)对外提供publicloose coupling
一个类的修改不影响其它类
high cohesion
一个类只完成一件事javaencapsulationcouplingcohesion
麻烦哪位高手,能否给补充一个定义?谢谢!well encapsulation
1)成员变量、方法private
2)对外提供publicloose coupling
一个类的修改不影响其它类
high cohesion
一个类只完成一件事javaencapsulationcouplingcohesion
对于思想,当然是抓住“面向对象(Object Oriented)”,像个正常人去考虑问题。
封装良好:隐藏对象的属性和实现细节,仅对外公开借口,并且控制访问级别(深藏功与名)
松耦合:耦合指各个模块之前的关联程度。
高聚合:聚合是指一个模块内部各个部分之间的关联程度
other classes only through their APIs.Cohesion is the OO principle most closely associated with making sure a class is designed
with a single, well-focused purpose.Polymorphism is the OO principle most closely associated with allowing a single object to be
seen as having many types.