数据拉与推OOP方法 [英] Data Pull vs. Push OOP Approach
问题描述
在OOP设计中有什么像标准,我应该更喜欢数据拉对象,而不是数据推送到对象?
任何人都可以从长期观点,或者当OOP结构/框架/图获得更复杂?
根据请不要问,推更好 - 或更多OO。你不想查询对象的数据,所以你可以做一些事情,你想要对象来做,因为他是知道他的数据的人。
When I design my system from scratch, I often face a dilemma whether my object should push information into another objects OR whether the objects should pull the necessary data from another objects.
Is there anything like a standard in OOP design, that I should prefer data pull by objects, versus data push into objects?
Can anyone experienced advise, whether one approach is better over the other from longer term viewpoint, or when the OOP structure/framework/diagram gets more complex?
According to tell dont ask, push is better - or more OO. You don't want to query object for data so you can do something, you want object to do it, because he's the one who knows his data.
Related article about evil getters
这篇关于数据拉与推OOP方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!