抽象,我做得太多了吗?

发布于 2024-10-04 22:19:30 字数 174 浏览 7 评论 0原文

我正在使用 SDL、OpenGL、物理引擎和嵌入式脚本语言编写游戏。

过去几周我一直在做的事情:抽象。我编写了代表程序本身、纹理、字体、物理对象等的抽象类。

  • 我是否抽象太多了,或者我怎么知道我是否抽象太多?
  • 在进入实际开发之前首先抽象所有库是一个好的做法吗?

I'm writing a game with a SDL, OpenGL, a physics engine and an embedded scripting language.

The thing I have been doing in the last weeks: Abstracting. I have written abstraction classes representing the program itself, textures, fonts, physics objects, and more.

  • Am I abstracting too much, or how can I know if I am?
  • Is this good practice at all to abstract all libraries first before getting into the actual development?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

猥︴琐丶欲为 2024-10-11 22:19:30

看看这里:多少抽象才算太多?< /strong>

基本上,您需要进行某种成本效益分析。如果您可以轻松理解抽象概念并且它能为您的游戏带来切实的好处,那么就去做吧。如果它开始使事情变得不必要的复杂并且很难理解它所抽象的内容,那么它可能不值得。存在收益递减点,但找到它并证明另一层间接是否是一个好主意是一门困难的艺术。

这是一个好的做法吗?
首先抽象所有库
进入实际开发了吗?

如果您是唯一的开发人员,那么它将很大程度上取决于您的个人喜好。如果您熟悉图书馆并且可以轻松地知道发生了什么,那么就没有问题。如果涉及其他人,那么这取决于您的抽象使用起来有多容易,以及学习它是否比使用没有任何附加层的实际库更好。

Take a look here: how much abstraction is too much?

Basically you need to do some sort of cost-benefit analysis. If you can easily understand the abstraction and it makes tangible benefits to your game, then go for it. If it starts to make things unnecessarily complicated and it makes it hard to understand what it being abstracted, then its probably not worth it. There's a point of diminishing returns, but finding it and justifying whether another layer of indirection is a good idea or not is a difficult art.

Is this good practice at all to
abstract all libraries first before
getting into the actual development?

If you are the only developer then its going to revolve largely around your personal preference. If you are familiar with the library and can tell what's going on easily, then you're fine. If others are involved, then it depends on how easy your abstraction is to use and if learning it better than using the actual library without any addition layers.

戒ㄋ 2024-10-11 22:19:30

由于您的目标是创建游戏,那么我建议您摆脱迄今为止创建的所有抽象层。直接使用您拥有的任何库。

把所有的时间都花在让东西在屏幕上移动上,这样你就可以尽快尝试你的游戏想法和设计。额外的抽象层会减慢这个过程。

当你达到了某个部分目标后,然后花固定的时间来清理代码。您可以在此处添加抽象来解决具体问题。但不要做得太过分。

然后继续创建您的游戏。最终,抽象与游戏的乐趣或上瘾程度没有多大关系。

Since your goal is to create a game, then I would recommend you to get rid of all layers of abstraction you have created so far. Use whatever libraries you have directly.

Spend all your time on getting stuff moving on the screen so that you can try out your game ideas and designs as quickly as possible. Having extra layers of abstraction will slow down this process.

When you have reached some part goal, then spend a fixed amount of time to clean up the code. This is where you add abstractions to solve your concrete problems. But don't overdo it.

Then continue creating your game. In the end abstractions will have very little to do with how fun or addicting the game is.

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