开发者

Re-organizing C++ code for memory and external dependencies management

开发者 https://www.devze.com 2023-02-05 02:07 出处:网络
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 d

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 t开发者_运维百科hese 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).


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.


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:

0

精彩评论

暂无评论...
验证码 换一张
取 消