# Which initial is preferred for a non-type template parameter, N or V (\`NDimension\` or \`VDimension\`)?

**URL:** https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788
**Category:** Engineering
**Created:** [February 7, 2022, 12:57pm UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788 "2022-02-07T12:57:34Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [February 7, 2022, 12:57pm UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/1 "2022-02-07T12:57:34Z")

</div>

According to our KWStyle file, a template parameter name must begin with either `T`, `N`, or `V`, if I understand correctly:

> <https://github.com/InsightSoftwareConsortium/ITK/blob/v5.3rc03/Utilities/KWStyle/ITK.kws.xml#L17>

`T` is for type parameters, obviously. But which prefix is preferred for non-type parameters? `N` (for _ **N** _on-type, or _ **N** _umeric) or `V` (for _ **V** _alue)?

I see both `NDimension` and `VDimension` in the ITK repo. No big deal, of course. I’m just wondering if there’s a preference anyway.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [February 7, 2022, 4:26pm UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/2 "2022-02-07T16:26:13Z")

</div>

I thought that `V` is preferred (`VDimension`), but I don’t know. Maybe someone from history of that file could answer?

---

<div class="post-metadata">

### Author: ![Lee\_Newberg](https://discourse.itk.org/user_avatar/discourse.itk.org/lee_newberg/32/1461_2.png) [@Lee\_Newberg](https://discourse.itk.org/u/Lee_Newberg)
#### Post date: [February 7, 2022, 4:39pm UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/3 "2022-02-07T16:39:00Z")

</div>

In existing code, `NDimensions?` is found 1638 times and `VDimensions?` is found 1718 times. People seem to be fairly split on this. Strangely, `VDimension` is seldom plural but `NDimensions` is seldom singular.

```bash
cd git/ITK
find . -type f | egrep '\.(h|c)(xx|pp|)$' | fgrep -v ThirdParty | \ 
    xargs egrep '[^A-Za-z_]NDimensions?[^A-Za-z_]' | wc -l
find . -type f | egrep '\.(h|c)(xx|pp|)$' | fgrep -v ThirdParty | \ 
    xargs egrep '[^A-Za-z_]VDimensions?[^A-Za-z_]' | wc -l

```

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [February 7, 2022, 5:31pm UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/4 "2022-02-07T17:31:04Z")

</div>

> [@Lee\_Newberg](#):
>
> In existing code, `NDimensions?` is found 1638 times and `VDimensions?` is found 1718 times. People seem to be fairly split on this. Strangely, `VDimension` is seldom plural but `NDimensions` is seldom singular.

Thanks for the statistics, @Lee_Newberg 👍

Strictly speaking one might say that an _N_-dimensional image has _N_ dimensions (plural). But as `itk::ImageBase::ImageDimension` is singular, I got used to it, eventually 😃

I think I mostly use the `N` as prefix for non-type template parameters, but I wouldn’t mind switching to `V`, if that would be preferred.

---

<div class="post-metadata">

### Author: ![Lee\_Newberg](https://discourse.itk.org/user_avatar/discourse.itk.org/lee_newberg/32/1461_2.png) [@Lee\_Newberg](https://discourse.itk.org/u/Lee_Newberg)
#### Post date: [February 7, 2022, 6:03pm UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/5 "2022-02-07T18:03:15Z")

</div>

My case-insensitive string search of the ITK Software Guide (April 2021) shows 10 instances of `unsigned int v`… as template parameters, but 0 for `unsigned int n`… as template parameters.

---

<div class="post-metadata">

### Author: ![Lee\_Newberg](https://discourse.itk.org/user_avatar/discourse.itk.org/lee_newberg/32/1461_2.png) [@Lee\_Newberg](https://discourse.itk.org/u/Lee_Newberg)
#### Post date: [February 7, 2022, 6:14pm UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/6 "2022-02-07T18:14:55Z")

</div>

More counting: there are 102 files that would need to be modified to change `N` template parameters to `V` template parameters across the board.

```bash
cd git/ITK
find . -type f | egrep '\.(h|c)(pp|xx)?$' | fgrep -v ThirdParty | \
    xargs egrep -l '<(.*, )*(unsigned )?int N[A-Za-z_]*(, .*)*>' | wc -l

```

There are 39 distinct changes involved:

```auto
cd git/ITK
find . -type f | egrep '\.(h|c)(pp|xx)?$' | fgrep -v ThirdParty | \
    xargs egrep -o '<(.*, )*(unsigned )?int N[A-Za-z_]*(, .*)*>' | \
    cut -d : -f 2 | sort | uniq -c | fgrep --color=always ' N'

```

---

<div class="post-metadata">

### Author: ![Lee\_Newberg](https://discourse.itk.org/user_avatar/discourse.itk.org/lee_newberg/32/1461_2.png) [@Lee\_Newberg](https://discourse.itk.org/u/Lee_Newberg)
#### Post date: [February 8, 2022, 12:20am UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/7 "2022-02-08T00:20:25Z")

</div>

I made a pull request to change `N` prefix to `V` and to change `Dimensions` to `Dimension`: [https://github.com/InsightSoftwareConsortium/ITK/pull/3171](https://github.com/InsightSoftwareConsortium/ITK/pull/3171)

---

<div class="post-metadata">

### Author: ![Niels\_Dekker](https://discourse.itk.org/letter_avatar_proxy/v4/letter/n/9d8465/32.png) [@Niels\_Dekker](https://discourse.itk.org/u/Niels_Dekker)
#### Post date: [February 8, 2022, 10:10am UTC](https://discourse.itk.org/t/which-initial-is-preferred-for-a-non-type-template-parameter-n-or-v-ndimension-or-vdimension/4788/8 "2022-02-08T10:10:46Z")

</div>

Great job, @Lee_Newberg

Personally I still like the `N` for _ **N** _on-type (_ **N** _umeric) parameters but you convinced me that there is a majority for `V`.
