要将多个元素作为一个对象来处理,您需要将它们组合。例如,创建了一幅绘画后(如树或花),可以将该绘画的元素合成一组,这样就可以将该绘画当成一个整体来选择和移动。
这样就可以装配组合对象,而不会造成把所有成员在类中声明可能造成的一般冲突和交互。
That gives you a way to assemble composite objects without the usual collisions and interactions possible if all members were declared in the class itself.
如果大消息主要是一些小业务对象的集合,那么解决方案是将这些小对象组合为一些小于1 MB的组合对象。
If the large message is primarily a collection of smaller business objects then the solution is to group the smaller objects into conglomerate objects less than 1mb in size.
将对象组合成树形结构以表示“部分-整体”的层次结构,使得用户对单个对象和组合对象的使用具有一致性。
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Could be ints, could be floats, could be a combination of things, some ints, some floats, some lists, some strings, some lists of lists, whatever.
但是我们知道数组内部的元素,可以是任何对象,可能是整数也可能是浮点数,也可能是对象的组合,一些整数。
Now, you might have said, gee, why didn't it just assume that I wanted to in fact treat these as strings, and combine them together?
现在,你们可能会认为,伊,为什么Python不假设,我实际上想把这些对象当做字符串一样对待,然后把它们组合到一起呢?
应用推荐