重组 C++内存和外部依赖管理的代码

发布于 2024-10-12 10:26:02 字数 763 浏览 9 评论 0原文

我有一个相当大的软件,在过去 10 个月里一直在开发。它是一个商业应用程序,因此从一开始(并且由于非编程要求),开发就更加注重提供新功能而不是构建强大的系统。

现在,我们正处于某个阶段,希望向应用程序添加以下功能:

  • 自己的内存管理系统,包括内存泄漏检测。
  • 为了使标准库的替换尽可能简单(假设:某人将使用我们的代码并希望使用他自己的字符串实现而不是 std::string),
  • 请准备多个版本。主要是“调试”版本,其中启用了内存泄漏检测、断言和其他“安全”技术等功能,以及“发布”版本,没有所有这些消耗过程。

关键是我可以找到手册来完成这些任务中的每一项,但我担心单独遵循每一项任务会让我的代码有点混乱。换句话说,我需要的是代码/标头组织的结构(也称为良好的设计),它允许我执行这些任务(也许将来还有其他任务)。

所以问题是,您是否知道任何参考书或在线书籍/手册,我可以在其中找到组织代码以完成所有这些功能的指南?有什么建议吗?

非常感谢。

此致。

编辑:

实际上我们正在开发应用程序和库......但在这种情况下我们要修改的部分是库,所以 Fred Nurk 你是没错,它是一个图书馆

关于IDE,我们使用的是Microsoft Visual Studio。我们正在 Windows 上开发该平台,但该库旨在跨平台工作(它与游戏编程相关,因此该库也可以在控制台和移动设备上工作)。

I have a fairly large piece of software that I have been developing for the last 10 months. It is a commercial application, so from the very beginning (and owing to non-programming requirements) the development has been more focused in providing new features than building a robust system.

Now we are at a certain stage when we want to add to the application the following features:

  • Own memory management system, including memory leak detection.
  • To make the substitution of standard libraries as easy as possible (let's say: somebody it's going to use our code and wants to use his own string implementation instead of the std::string)
  • Prepare several releases. Mainly, a 'Debug' version where things like memory leak detection, assertions and other "safe" technics are on, and a 'Release' version, without all these consuming procedures.

The point is that I can find manuals out there to do each one of these tasks, but I am afraid that following each one of them separately take me to have a code a bit messy. In other words, what I need is a structure of code/headers organization (aka, a good design) that allows me to carry on these tasks (and maybe others in the future).

So the question is, do you know any reference or online books/manuals where I can find a guideline to organize the code in order to accomplish all these features? Any suggestions?

Many thanks in advance.

Best regards.

EDIT:

Actually we are developing both, an application and a library... but the part we are going to modify in this case is the library, so Fred Nurk you are right, it is a library.

About IDE, we are using Microsoft Visual Studio. The platform, we are developing on Windows, but the library is intended to work cross-platform (it is game programming related, so the library will work on consoles and mobiles too, for instance).

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

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

发布评论

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

评论(2

污味仙女 2024-10-19 10:26:02

听起来您正计划进行一次重大重构,在这种情况下您可能应该阅读 重构:改进现有代码的设计作者:Martin Fowler。

It sounds like you are planning to undertake a major refactoring, in which case you should probably read Refactoring: Improving the Design of Existing Code by Martin Fowler.

冷血 2024-10-19 10:26:02

使用 std::string 并强制使用它是合理的,但您不应该假设其他人将使用与您自己相同的 STL 实现。

有多种方法可以通过定义良好的接口来做到这一点。

关于该主题的书籍,Martin Fowler 可能是该部门最著名的“大师”:

It is reasonable to use std::string and enforce its use, but you should not assume that others will be using the same STL implementation as yourselves.

There are ways to do this with well-defined interfaces.

With regards to books on the subject, Martin Fowler is probably the best-known "guru" in this department:

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