Small

Keeping objects small makes them easier to understand, less complex and easier to change in the future

Smells

Large number of constructor arguments

If the object is becoming difficult to construct due to the number of argument. Now is the time to break it down. Avoid creating builders or factories to try and hide this problem. look for groups of arguments that could become objects in their own right. A similar symptom can be a large number of getter methods.

Private static methods

Private static methods can be an indicator that your object needs to be broken down. A private methods that doesn’t need access the objects state, and has values passed to them as parameters to operate on can also be a sign that a new object should be created.

You may have something like…

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

  class Person {
      private static formatName(String firstName, String lastName) {
      return firstName + " " + lastName;
    }

      public String sayHello() {
      return "Hi, i'm " + formatName(this.firstName, this.lastName);
    }
  }

That can be turned into ….

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12

  class Name {
      public String getFullName() {
      return this.firstName + " " + this.lastName;
    }
  }

  class Person {
      public String sayHello() {
      return "Hi, i'm " + this.name.getFullName();
    }
  }