Search⌘ K

Identifying a Group of Core Methods

Explore how to define and test core methods in Java classes using array-based structures. Learn to focus on fundamental methods such as add, isFull, and toArray to simplify development and enable effective testing before completing the full class implementation.

A strategy for defining a class

The definition of the class BagOfStrings could be fairly involved, as it certainly has quite a few methods. For such classes,

  • Do not define the entire class all at once and then attempt to test it.
  • Instead, we should identify a group of methods central to the purpose of the class to both implement and test before continuing with the rest of the class definition. Such methods are core methods, and sometimes we will refer to a group of core methods as a core group.

By leaving the definitions of the other methods for later, we can ...