本文介绍了UML用于C编程语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UML最常用于使用C ++建模系统。在我的项目中,C是实现语言。我正在寻找适用于C的UML策略的资源。我想在设计过程中使用UML,代表系统的不同方面。

解决方案

我不知道有什么现有资源讨论使用UML专门为C。如其他人所说,UML是语言无关的。



保持请记住,使用UML,您可以有一个问题域的模型,另一个用于实现。尽量不要用C来对问题领域进行建模,而应该是高级别的OO。一旦您充分了解问题域,就可以开始对实现进行建模。



对于建模过程式C实现,以下图可能很有用:




  • 类图:


    • 显示C模块API

    • 显示C模块关系(主要是非OO的依赖关系)

    • 显示结构和枚举(使用<< stereotype>)


  • 包图:显示库的内容(模块)以及库之间的依赖关系

  • 活动图:流程图的非平凡算法

  • 顺序/协作图:显示模块/实体/输入/输出之间的事件/消息如何及时发生

  • 状态图:对于状态机,当然!



在类图上展开,您可以以下列方式对其进行滥用:对程序式C:




  • Glo外部函数 - > public方法

  • 本地静态函数 - >私有方法

  • 全局外部变量 - > public成员

  • 本地静态变量 - >私有成员

  • 结构 - >具有struct原型的类

  • 定义常量 - >类使用枚举原型




实验,你会发现自己的滥用UML的惯例。


UML is most commonly used for modelling system by using C++. In my projects C is the implementation language. I am looking for resources on UML strategies which are applicable for C. I want to use UML during design and represent the different aspects of the system.

解决方案

I don't know of any existing resources that discuss using UML specifically for C. As others have mentioned, UML is language-agnostic.

Keep in mind that with UML, you can have a model for the problem domain, and another for the implementation. Try not to model the problem domain in terms of C, but rather as high-level OO. Once you understand the problem domain adequately enough, you can begin modeling an implementation.

For modeling procedural-style C implementations, the following diagrams could be useful:

  • Class diagram:
    • Show C module APIs
    • Show C module relationships (mostly dependencies for non-OO)
    • Show structures and enumerations (using < < stereotype> >)
  • Package diagram: Show contents (modules) of libraries, and the dependency relationships between libraries
  • Activity diagram: Flowcharting non-trivial algorithms
  • Sequence/collaboration diagram: Show how events/messages between modules/entities/inputs/outputs occur in time
  • Statechart diagram: For state machines, of course!

Expanding on class diagrams, you can "abuse" them in the following way for procedural-style C:

  • Global extern functions -> public methods
  • Local static functions -> private methods
  • Global extern variables -> public members
  • Local static variables -> private members
  • Structs -> class with "struct" stereotype
  • define constants -> class with "enumeration" stereotype

Experiment, and you'll find your own conventions for abusing UML.

这篇关于UML用于C编程语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 05:49