We behave to meet our needs: to either get something or to avoid something. When we try to determine what that need is, we're looking for the behavior's function.
Behaviors are learned. Maladaptive behaviors, while perhaps meeting a need, do so in way that cause undesirable consequences. To meet needs without causing undesirable consequences requires learning and practicing new behaviors.
Behaviors do not exist in a vacuum and are determined by both antecedents and consequences. Antecedents influence the behavior, and consequences influence the likelihood of that behavior happening again. This cycle of antedent-behavior-consequence is referred as the ABCs of behavior.
To determine the function of a behavior and the appropriate replacement behavior, antecedents and consequence must be examined. Behaviors do not exist in a vacuum and are determined by both antecedents and consequences.