Welcome to the Treehouse Community
Looking to learn something new?
Is there a simple definition and example for helper methods?
Helper methods are used to quickly ascertain the state of something within the class. Often, they are used to compare to zero, returning a true/false outcome that can help route code execution via an
if statement, for example. One of the courses on here uses a good example. A member variable (it is called
mBarsCount but it doesn't matter) has a maximum value defined by a constant in the class and the variable can be incremented an decremented as required by the code. Two helper methods exist for this variable, one to compare it to zero and the other to compare it to the defined max value. Both of these methods return a true or false outcome.
So, while it is possible to do either of these comparisons within your code, the use of helpers both removes duplication of code by creating a method for a commonly used requirement, and it makes the code easier to read (if you name the method sensibly!).
I hope that, erm, helps.