抽象,我做得太多了吗?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这里:多少抽象才算太多?< /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.
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.
由于您的目标是创建游戏,那么我建议您摆脱迄今为止创建的所有抽象层。直接使用您拥有的任何库。
把所有的时间都花在让东西在屏幕上移动上,这样你就可以尽快尝试你的游戏想法和设计。额外的抽象层会减慢这个过程。
当你达到了某个部分目标后,然后花固定的时间来清理代码。您可以在此处添加抽象来解决具体问题。但不要做得太过分。
然后继续创建您的游戏。最终,抽象与游戏的乐趣或上瘾程度没有多大关系。
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.