是否为 3d 点的值对象?

发布于 2024-08-25 03:21:11 字数 238 浏览 4 评论 0原文

我需要用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走就滚别墨迹 2024-09-01 03:21:11

我对其他库不熟悉,但似乎 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文