我应该如何构建复杂的项目用C? [英] How should I structure complex projects in C?

查看:122
本文介绍了我应该如何构建复杂的项目用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我比初学者C级的技能更多一点,想知道是否有任何事实上的标准结构C.即使基于GUI的人有点复杂的应用程序。

I have little more than beginner-level C skills and would like to know if there are any de facto "standards" to structure a somewhat complex application in C. Even GUI based ones.

我一直一直在使用Java和PHP的面向对象的范例,现在我想学习C我怕我会组织我的应用程序中的错误的方式。我在亏损上指引,有模块化,解耦和干燥用程序语言。

I have been always using the OO paradigm in Java and PHP and now that I want to learn C I'm afraid that I might structure my applications in the wrong way. I'm at a loss on which guidelines to follow to have modularity, decoupling and dryness with a procedural language.

你有什么阅读建议?我找不到任何C应用程序的框架,即使我不通过浏览他们的code使用框架,我总觉得不错的想法。

Do you have any readings to suggest? I couldn't find any application framework for C, even if I don't use frameworks I've always found nice ideas by browsing their code.

推荐答案

的关键在于模块化。这种情况很容易设计,实施,编制和维护。

The key is modularity. This is easier to design, implement, compile and maintain.


  • 识别模块在你的应用程序,就像在OO应用程序类。

  • 分离接口和实现每个模块,放于界面由其他模块仅需要什么。请记住,在C没有命名空间,所以你必须让一切在你的界面唯一的(例如,以preFIX)。

  • 隐藏全局变量在实施和使用存取功能的读/写。

  • 请不要觉得在继承方面,而且在组成上。作为一般规则,不要试图模仿C ++中的C,这将是非常困难的阅读和维护。

如果您有时间学习,看看一个阿达应用程序是如何构成的,其强制性(模块接口)和包身体(模块实现)。

If you have time for learning, take a look at how an Ada app is structured, with its mandatory package (module interface) and package body (module implementation).

这是编码。

有关维护(记住,你code一次,但是你保持好几次)我建议你记录code; Doxygen的对我来说是一个不错的选择。我还建议建立一个强大的回归测试套件,它允许您重构。

For maintaining (remember that you code once, but you maintain several times) I suggest to document your code; Doxygen is a nice choice for me. I suggest also to build a strong regression test suite, which allows you to refactor.

这篇关于我应该如何构建复杂的项目用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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