# Globally unique class names

**URL:** https://discourse.openehr.org/t/globally-unique-class-names/2068
**Category:** Specifications
**Created:** [12 November 2021 09:00 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068 "2021-11-12T09:00:23Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![borut.jures](https://discourse.openehr.org/user_avatar/discourse.openehr.org/borut.jures/32/1391_2.png) [@borut.jures](https://discourse.openehr.org/u/borut.jures)
#### Post date: [12 November 2021 09:00 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/1 "2021-11-12T09:00:23Z")

</div>

EXPR\_TYPE\_DEF is specified in two files:

- `components/LANG/Release-1.0.0/openehr_lang_100.bmm`

- `components/BASE/Release-1.0.4/openehr_expression_104.bmm`.

All the other types in “lang\_100” have the name “TYPE\_abc”. Only “EXPR\_TYPE\_DEF” has the “EXPR\_” prefix.

All the types in “expression\_104” have the prefix “EXPR\_”.

```auto
expression_104:
"EXPRESSION",
"EXPR_VALUE",
"EXPR_VARIABLE_REF",
"EXPR_LEAF",
"EXPR_OPERATOR",
"EXPR_LITERAL",
"EXPR_UNARY_OPERATOR",
"EXPR_BINARY_OPERATOR",
"EXPR_VALUE_REF",
"EXPR_FUNCTION",
"EXPR_TYPE_DEF"

lang_100:
"EXPR_TYPE_DEF", <== the odd one
"TYPE_DEF_BOOLEAN",
"TYPE_DEF_INTEGER",
"TYPE_DEF_REAL",
"TYPE_DEF_DATE",
"TYPE_DEF_DATE_TIME",
"TYPE_DEF_TIME",
"TYPE_DEF_DURATION",
"TYPE_DEF_STRING",
"TYPE_DEF_URI",
"TYPE_DEF_TERMINOLOGY_CODE"

```

Name “TYPE\_DEF” is not used anywhere else. Shouldn’t “EXPR\_TYPE\_DEF” in the “lang\_100” use “TYPE\_DEF” to follow the same pattern as the rest of the classes?

“expression\_104” is included in `components/AM/openEHR_am_230.bmm` which is also odd since the “am\_230” also includes “base\_110”. I would expect there would also be “expression\_110” (even if it is the same as expression\_104).

* * *

I found out this when an UML diagram for EXPR\_LEAF included “EXPR\_TYPE\_DEF” from “lang\_100” instead of “expression\_104”.

As @thomas.beale mentioned before, using full package names for classes solves this. However I try to keep URLs for the diagrams as short as possible (also specifying classes to include on the custom diagrams can be done only using a name).

Using unique class names (if possible) would also simplify mentioning them in an unambiguous way.

So far I found only 2 non-unique class names:

- EXPR\_TYPE\_DEF in “lang\_100” and “expression\_104”
- EVENT in “proc\_160” and “rm\_structures\_nnn”

* * *

I guess it isn’t possible to change the naming at this point (?) and I’ll have to use longer URLs for the diagrams?

First option is to add `model_name` to the URLs. But “TASK\_PLANNING” is much longer than “PROC”.

The second option is to add “PROC”, “LANG”,… to the urls.

What are the community’s preferences for the URL naming?

---

<div class="post-metadata">

### Author: ![borut.jures](https://discourse.openehr.org/user_avatar/discourse.openehr.org/borut.jures/32/1391_2.png) [@borut.jures](https://discourse.openehr.org/u/borut.jures)
#### Post date: [12 November 2021 11:17 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/2 "2021-11-12T11:17:11Z")

</div>

I started adding full namespace support to the validator and realised that even BMM is not using namespaces.

Example: components/PROC/Release-1.6.0/openehr\_proc\_task\_planning\_latest.bmm

```auto
["PARAMETER_DEF"] = <
    name = <"PARAMETER_DEF">
    properties = <
        ["name"] = (P_BMM_SINGLE_PROPERTY) <
            name = <"name">
            type = <"String">
            is_mandatory = <True>
        >
        ["type"] = (P_BMM_SINGLE_PROPERTY) <
            name = <"type">
            type = <"EXPR_TYPE_DEF"> <== which EXPR_TYPE_DEF is this (LANG or BASE)?
            is_mandatory = <True>
        >

```

Since property types don’t specify package names, we don’t know which type/class is meant. In the above example either EXPR\_TYPE\_DEF from “lang\_100” or from “expression\_104” could be used.

This wasn’t an issue before “lang\_100” and “proc\_100” since before that all the classes were globally unique.

I’m I missing something and non-unique class names can be used for properties without also specifying their package?

---

<div class="post-metadata">

### Author: ![sebastian.iancu](https://discourse.openehr.org/user_avatar/discourse.openehr.org/sebastian.iancu/32/31_2.png) [@sebastian.iancu](https://discourse.openehr.org/u/sebastian.iancu)
#### Post date: [12 November 2021 11:34 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/3 "2021-11-12T11:34:43Z")

</div>

I think there is a need for a package dependency maps: some specs release requires others to be used, or are not compatible with others.  
I this case (@thomas.beale better correct me), the EL was part of BASE 1.0.4, but later was extracted as a separate component EL 1.0.0 (which supposed to be used with BASE 1.1+). There are similar issues on AM 1.4 and AOM Profile vs BASE, or BASE vs RM 1.0.2. this dependencies are nowhere expressed in a computational form (as far as I know).

---

<div class="post-metadata">

### Author: ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)
#### Post date: [12 November 2021 11:59 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/4 "2021-11-12T11:59:11Z")

</div>

The EXPR\_TYPE\_DEF classes were experimental and are discontinued, so you could rename this however you want; for EVENT, I suggest for now you rename it in your private clone as ‘PLAN\_EVENT’, which we’ll probably do one day anyway. No need to complicate things in your local setup for now.

---

<div class="post-metadata">

### Author: ![borut.jures](https://discourse.openehr.org/user_avatar/discourse.openehr.org/borut.jures/32/1391_2.png) [@borut.jures](https://discourse.openehr.org/u/borut.jures)
#### Post date: [12 November 2021 12:17 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/5 "2021-11-12T12:17:44Z")

</div>

OK. I’ll rename it locally for now.

I’ll rename EVENT to BASE\_EVENT, since PLAN\_EVENT already exists in PROC.

* * *

I guess this means that I can stop adding support for namespaces when validating BMMs 🤔

---

<div class="post-metadata">

### Author: ![erik.sundvall](https://discourse.openehr.org/user_avatar/discourse.openehr.org/erik.sundvall/32/1961_2.png) [@erik.sundvall](https://discourse.openehr.org/u/erik.sundvall)
#### Post date: [12 November 2021 17:58 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/6 "2021-11-12T17:58:53Z")

</div>

Having unique class names would be great for keeping the upcoming URN syntax short/compact too.

---

<div class="post-metadata">

### Author: ![borut.jures](https://discourse.openehr.org/user_avatar/discourse.openehr.org/borut.jures/32/1391_2.png) [@borut.jures](https://discourse.openehr.org/u/borut.jures)
#### Post date: [12 November 2021 19:04 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/7 "2021-11-12T19:04:23Z")

</div>

I see two options at the moment:

1. Use package name + type name when specifying property type in BMMs. That would be unreadable due to the length.
2. Keep using class names as globally unique. This doesn’t mean we shouldn’t use namespaces for working classes (I use short URL but in the backend I use package names + class name).

Most class names are unique without trying. Only the EVENT in PROC is non-unique and it can get some prefix to make it unique.

To me the most important part of having unique names is that everybody knows about which class we are talking about (without mentioning its model/package).

---

<div class="post-metadata">

### Author: ![thomas.beale](https://discourse.openehr.org/user_avatar/discourse.openehr.org/thomas.beale/32/35_2.png) [@thomas.beale](https://discourse.openehr.org/u/thomas.beale)
#### Post date: [12 November 2021 19:45 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/8 "2021-11-12T19:45:27Z")

</div>

> [@borut.jures](#):
>
> To me the most important part of having unique names is that everybody knows about which class we are talking about (without mentioning its model/package).

That is our general approach as well; I’m not sure why we didn’t call PROC:EVENT something unique. But this can be changed, so we can solve it.

---

<div class="post-metadata">

### Author: ![pablo](https://discourse.openehr.org/user_avatar/discourse.openehr.org/pablo/32/3505_2.png) [@pablo](https://discourse.openehr.org/u/pablo)
#### Post date: [12 November 2021 19:55 UTC](https://discourse.openehr.org/t/globally-unique-class-names/2068/9 "2021-11-12T19:55:55Z")

</div>

IMHO with package+class being unique is enough, though having all classes from all models banned uniquely would be a quality sign.
