Skip to main content

Code reviews rule: Inconsistent naming Apex inner classes

Written by David Martin
Updated this week

Inconsistent naming Apex inner classes

Why is this an issue?

Naming conventions help drive consistency across the application, making source code easier to read and understand. Inner classes should follow the same PascalCase naming convention as top-level classes.

Examples

Example of incorrect code:

public class AccountService {
public class account_wrapper {
public String name;
}
}

Example of correct code:

public class AccountService {
public class AccountWrapper {
public String name;
}
}

How can I fix violations?

Rename the inner class to use PascalCase (also known as UpperCamelCase), where each word starts with a capital letter and there are no underscores.

Configuration options

You can configure the pattern the inner class must follow.

Resources

Did this answer your question?