<commit_before>---
title: Naming Conventions
headline: Naming Conventions
bodyclass: docs
layout: docs
sidenav: doc-side-guides-nav.html
type: markdown
---

<p>This document covers naming conventions for the code. Some of these contentions are used by 
the framework and code generation, and as such are required. Others are our recommendations that 
we find useful for making things clear and structuring the code.</p>

## Proto files

Proto files are named using the `snake_case`, as defined by Protobuf. There are several special
kinds of files.

### Identifiers   

Commands and events reference model entities using their identifiers. 
Having typed identifiers makes a model type safe.
Although the framework also supports `String`, `Integer`, and `Long` as valid ID types, 
we strongly recommend defining custom ID types like `CustomerId`, `OrderId`, `ShipmentId`, and others. 
You can find similar cases in the framework API which has `EventId`, `CommandId`, `UserId`, 
`TenantId`, and others. 

We find it convenient to define ID types in one file called `identifiers.proto`. 
A typical project is likely to have more than one Bounded Context, thus you will have several `identifiers.proto` files. 
Each of them resides under the directory with proto files defining the data model of the corresponding Bounded Context.   

### Command definitions

Commands are defined in a file ending with `commands.proto`. 
It can be simply `commands.proto` but usually commands are handled by different entities. 
Thus it is convenient to name such file after the type of a target entity, 
for example, an aggregate: 

 * `blog_commands.proto` 
 * `order_commands.proto` 
 * `customer_commands.proto`<commit_msg>Adding a note on using `java_outer_classname` in proto files to address issue #102 in Naming Conventions guide.<commit_after>---
title: Naming Conventions
headline: Naming Conventions
bodyclass: docs
layout: docs
sidenav: doc-side-guides-nav.html
type: markdown
---

<p>This document covers naming conventions for the code. Some of these contentions are used by 
the framework and code generation, and as such are required. Others are our recommendations that 
we find useful for making things clear and structuring the code.</p>

## Proto files

Proto files are named using the `snake_case`, as defined by Protobuf. There are several special
kinds of files.

<p class="note">We recommend using `java_outer_classname` in proto files names to make their names obvious. Otherwise Protobuf Compiler tries to use the name of the file for the Java class. For example, for `identifiers.proto` it will be `Identifiers.java`. Though sometimes it can be `SomethingOuterClass` when there is a type which conflicts with CamelCase version of the file name.
You may also want to use names like `Identifiers` for utility classes related to your domain.</p>

### Identifiers   

Commands and events reference model entities using their identifiers. 
Having typed identifiers makes a model type safe.
Although the framework also supports `String`, `Integer`, and `Long` as valid ID types, 
we strongly recommend defining custom ID types like `CustomerId`, `OrderId`, `ShipmentId`, and others. 
You can find similar cases in the framework API which has `EventId`, `CommandId`, `UserId`, 
`TenantId`, and others. 

We find it convenient to define ID types in one file called `identifiers.proto`. 
A typical project is likely to have more than one Bounded Context, thus you will have several `identifiers.proto` files. 
Each of them resides under the directory with proto files defining the data model of the corresponding Bounded Context.   

### Command definitions

Commands are defined in a file ending with `commands.proto`. 
It can be simply `commands.proto` but usually commands are handled by different entities. 
Thus it is convenient to name such file after the type of a target entity, 
for example, an aggregate: 

 * `blog_commands.proto` 
 * `order_commands.proto` 
 * `customer_commands.proto`
{'fraction_non_alphanumeric': 0.06156156156156156, 'fraction_numerical': 0.0007507507507507507, 'mean_word_length': 4.629577464788732, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '94927', 'n_tokens_mistral': 1034, 'n_tokens_neox': 999, 'n_words': 556}