UML的命名约定 [英] Naming convention for UML

查看:134
本文介绍了UML的命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UML是否有任何名称约定?

Is there any name convention for UML?

我对知道如何命名类,包和方法感兴趣.但是,如果有一些文档为每个UML图指定了所有命名约定,请共享它.

I am interested in knowing how to name classes, packages and methods. However, if there is some document which specifies all naming convention for each UML diagram, please share it.

推荐答案

UML标准未指定任何命名约定.您选择的命名标准取决于UML模型的目标受众.该受众再次取决于您模型的目的.如果您打算从模型生成代码,而不需要获得适合目标平台的结果.我自己的经验是,即使您希望在更改目标平台后仍保留模型,或者打算为多个目标平台生成代码,选择独立于平台的命名会很有帮助.例如.如果要创建Java代码,用于SQL数据库的DDL语句和用于Restful服务的XSD架构定义,则需要三个不同的目标,而这三个目标都需要使用通用语言.恕我直言,一种很好的方法是使用平台无关的类型系统,例如CORBA IDL,XSD类型甚至ISO类型.您还可以使用自然语言类型描述,例如日期",时间",数字",货币".对于域特定内容的名称,可以使用映射.例如.如果您将类别命名为客户联系人",并且将操作命名为致电客户",并将属性命名为客户名称",则映射将允许创建例如 Customer_Contact作为Java类名称,"callCustomer"作为操作名称,"customersName"作为属性名称.

The UML standard does not specify any naming convention. The naming standard you choose depends on the target audience of your UML model. This audience again is dependend on the purpose of your model. If you intend e.g. to generate code from your model than you need to have a result that will fit your target platform. My own experience is that choosing a platform independent naming is helpful if you would like to keep your model even after changing the target platform or if you intend to generate code for multiple target platforms. E.g. if you intend to create Java Code, DDL statements for your SQL database and XSD schema definitions for your Restful services than you have three different targets where you need a common language for all three targets. A good approach is IMHO to use platform independent type systems like CORBA IDL, XSD types or even ISO types. You could also use natural language type descriptions like "date", "time", "number", "currency". For the names of your Domain specific content you can use a mapping. E.g. if you name a Class "Customer Contact" and and operation "Call Customer", an Attribute "Customer's Name" then the mapping will allow to create e.g. Customer_Contact as the Java Class Name "callCustomer" as the operation Name and "customersName" as the attribute Name.

是否可以应用映射取决于所使用的工具链.如果无法使用映射,则必须确定目标平台中哪一个是最小公分母.如果没有,则必须决定不遵循命名约定的最省力的方法.

Whether you can apply mappings depends on the toolchain you are using. If you can't use mapping you'll have to decide which is least common denominator of your target platforms. If there is none you'll have to decide where it is the least effort to not follow the naming conventions.

恕我直言,最重要的是是否严格遵守了将模型元素映射到其他工件的规则和系统性的规则(甚至可以是自动化的),或者该模型是否用于说明目的,并且映射规则是否仅由涉及其大脑的人员应用

Most important is IMHO whether the rules for mapping model elements to other artifacts are stricly followed and systematic (may be even automated) or whether the model is used for illustrative purposes and the mapping rules are just applied by people involved using their brains.

这篇关于UML的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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