是否为 3d 点的值对象?
我需要用python开发一个几何库,描述3d空间中的点、线和面,以及各种几何操作。 与我之前的问题相关。
设计中的主要问题是这些实体是否应该具有身份。我想知道是否有一个类似的库(用另一种语言开发)可以从中获取灵感,选择的设计是什么,特别是一个选择与另一个选择的原因。
I need to develop a geometry library in python, describing points, lines and planes in 3d space, and various geometry operations. Related to my previous question.
The main issue in the design is if these entities should have identity or not. I was wondering if there's a similar library out there (developed in another language) to take inspiration from, what is the chosen design, and in particular the reason for one choice vs. the other.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对其他库不熟悉,但似乎 3d 点应该是(不可变的)值对象。
- 允许在多个容器(线、平面等)之间共享一个点
- 避免防守型进攻球员和二传球员
- 在现实生活中,3d 点没有身份。
另外,乔什·布洛赫 (Josh Bloch) 说(请参阅 http://www.infoq.com/presentations/有效的 API 设计
)他们在 Java 标准库设计中犯的错误之一是他们没有将 Size 类定义为不可变的。
I am not familiar with other libraries, but it seems that there 3d points should be (immutable) value objects.
- allows sharing of a point between several containers (lines, planes, etc.)
- Avoids defensive getters and setters
- In real-life a 3d point has no identity.
Also, Josh Bloch is saying (see http://www.infoq.com/presentations/effective-api-design
) that one of the mistakes they did in the design of Java's standard library was that they did not define the Size class as immutable.