Heart containing Coding Chica Java 101

Adjectives, Describing State! Boolean Java Variable Names

TIP: References Quick List

Table of Contents

  1. Table of Contents
  2. Introduction
  3. Java Boolean Variable Names
  4. Summary

Introduction

In Java, Boolean variables don’t strictly follow the noun or noun phrases variable naming approach from the last post.

Java Boolean Variable Names

In general, variables follow noun / noun phrasing naming conventions. For example:

private boolean child = false;

public boolean isChild() {
    return child;
}

However, boolean variables may often also be used to describe state, in which case, an adjective would apply:

private boolean running = true;

public boolean isRunning() {
    return running;
}

Either way, they should make sense with the getter naming convention, which is to prefix the variable name with is.

Summary

Because boolean variables may store state, they may not strictly adhere to the noun / noun phrase guidance from the prior post.

Adjectives, Describing State! Boolean Java Variable Names

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.