需要代码模块化的建议 [英] Need recommendations for code modularization

查看:58
本文介绍了需要代码模块化的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个巨大的C应用程序,其中大部分都在一个文件中。我想要b / b $ b将它模块化为几个不同的文件。是否有一个很好的

资源,用于学习将C文件链接在一起的最佳方式...和

可能会使用一些好的约定?


谢谢,

I inherited a huge C application and most of it is in one file. I''d
like to modularize it into several different files. Is there a good
resource for learning the best way to link C files together... and
maybe some good conventions to use?

Thanks,

推荐答案



ern写道:

ern wrote:
我继承了一个庞大的C应用程序,其中大部分都在一个文件中。我想把它模块化成几个不同的文件。有没有一个很好的资源来学习将C文件链接在一起的最佳方法......和
可能会使用一些好的约定?
I inherited a huge C application and most of it is in one file. I''d
like to modularize it into several different files. Is there a good
resource for learning the best way to link C files together... and
maybe some good conventions to use?




开始的地方:


1)全局变量:通过它们访问的变量划分函数。

2)结构定义:按函数划分函数

使用。


希望这会有所帮助。 karl m



Places to start:

1) global variables: divide the functions by the variables they access.
2) structure definitions: divide the functions by the structures they
use.

Hope this helps. karl m


ern写道:
我继承了一个庞大的C应用程序,其中大部分都在一个文件中。我想把它模块化成几个不同的文件。有没有一个很好的资源来学习将C文件链接在一起的最佳方法...和
可能会使用一些好的约定?
I inherited a huge C application and most of it is in one file. I''d
like to modularize it into several different files. Is there a good
resource for learning the best way to link C files together... and
maybe some good conventions to use?



您的编译器手册?


查找函数和变量的逻辑分组,并将它们保存在新文件中




你会发现最大的问题是在一个文件中将静态

变量(或函数)转换为全局/共享多个

文件。您要么必须使事物全局化,要么创建一些形式

的封装,具体取决于您的风格偏好。根据我的经验,

痛苦会带来更好的设计,但在开始这个过程之前,你最好有一套好的测试。


Ian


Your compiler manuals?

Look for logical groupings of functions and variables and keep them
together in the new files.

The biggest problem you will find will be converting between static
variables (or functions) in the one file to global/shared across many
files. You will either have to make things global, or create some form
of encapsulation, depending or you style preference. In my experience,
the pain will lead to a better design, but you had better have a good
set of tests before you start the process.

Ian


我目前正在经历同样的事情。我一直在尝试使用
来创建对全局变量起作用的访问器和mutator函数。

另外,我一直在使用一个名为Understanding for C ++的程序

Scientific Toolworks Inc( www.scitools.com)。它会生成很多关于代码的信息。例如,如果你点击一个变量,它就会告诉你它是被定义,使用和修改过的。它告诉你

函数调用其他函数。它节省了我很多时间,虽然成本只是一小步,但是b $ b。

I am currently going through the same thing. I have been trying to
make accessors and mutator functions that act on the global variables.
Also, I have been using a program called Understand for C++ by
Scientific Toolworks Inc (www.scitools.com). It generates a lot of
information about your code. For example if you click on a variable it
tells you were it is defined, used and modified. It tells you what
functions call other functions. It has saved me a great deal of time,
although the cost was a little step.


这篇关于需要代码模块化的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆