简体   繁体   English

生产代码中面向方面的C(非C ++)

[英]Aspect Oriented C (not C++) in Production Code

This is a question further derived from a previous one: https://stackoverflow.com/questions/1834485/aspect-oriented-programming-aop-in-c-not-c-anyone-doing-it 这是从上一个问题中进一步得出的一个问题: https : //stackoverflow.com/questions/1834485/aspect-iented-programming-aop-in-c-not-c-anyone-doing-it

The answers to that question point us to some research practices at queens university here: http://sailhome.cs.queensu.ca/~bram/aspicere/index.html . 该问题的答案使我们了解了皇后大学的一些研究实践: http : //sailhome.cs.queensu.ca/~bram/aspicere/index.html

Beyond that research effort, does anyone know of real world usage of Aspect Oriented C in production code? 除了研究工作之外,有人知道生产代码中面向方面的C在现实世界中的用法吗? If no, where do you think the difficulty is? 如果没有,您认为困难在哪里? If yes, what's the hurdle that makes it unpopular yet? 如果是,那么使它不受欢迎的障碍是什么?

I think the benefit of AOP is obvious. 我认为AOP的好处显而易见。 But after AOP-Java becoming popular for a decade, AOP-C is still almost non-existent, there must be some reason. 但是,在AOP-Java流行了十年之后,AOP-C仍然几乎不存在,这一定是有原因的。 What's your insight on this? 您对此有何见解?

After some thinking I believe the answer is that C lacks the structural constructs where you can hook up your aspect cross-cuts. 经过一番思考后,我相信答案是C缺乏可用于连接方面横切面的结构构造。

To get around of this problem, a project would have to impose strict structural conventions that is not easy to have programmers to agree on. 为了解决这个问题,一个项目必须施加严格的结构约定,这很难让程序员达成共识。 If you do have programmers to agree on to such a convention, the chance is that the project would have chosen a better language. 如果确实有程序员同意这样的约定,那么该项目很可能会选择更好的语言。

I think the main reason is that traditional method to implement the AOP in C/C++ needs a complex framework to make things work. 我认为主要原因是,在C / C ++中实现AOP的传统方法需要复杂的框架才能使工作正常。 Beside, the C++ is strict type language, which makes the implementation even harder than C. 另外,C ++是严格的类型语言,这使得实现比C还要困难。

But, It is the old time. 但是,这是旧时光。 new C++ 11~17 provides some really powerful features for you to do all the tricks. 新的C ++ 11〜17提供了一些非常强大的功能供您完成所有技巧。

You could check this one: https://github.com/whitebob/qaop A very light-weight, header-only AOP framework, and it is easy to use. 您可以检查以下内容: https : //github.com/whitebob/qaop一个非常轻巧,仅标头的AOP框架,并且易于使用。

I am the author of this on-going project, so if you have some suggestions or complains, just contact me :p 我是这个正在进行的项目的作者,因此,如果您有任何建议或投诉,请与我联系:p

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM