Code Smell 90 - Implementative Callback Events

Code Smell 90 - Implementative Callback Events

Maxi Contieri
·Oct 7, 2021·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

When creating events, we should decouple the trigger from the action.

TL;DR: Name your functions acording to what happened.



  1. Name the events after "what happened", not "what you should do"

Sample Code


const Item = ({name, handlePageChange)} =>
  <li onClick={handlePageChange}>

//handlePageChange is coupled to what you decide to do
//instead of what really happened
//We cannot reuse this kind of callbacks
const Item = ({name, onItemSelected)} =>
  <li onClick={onItemSelected}>

//onItemSelected will be called just when a item was selected. KISS
//Parent can decide what to do (or do nothing)
//We defer the decision


This is a semantic smell. We can detect it on peer code reviews.


  • Coupling

  • Naming


Names are very important. We should delay implementation coupled names until the very last moment.

More Info


Photo by Ashim D’Silva on Unsplash

Thanks to Maciej for this tip

Beyond basic mathematical aptitude, the difference between good programmers and great programmers is verbal ability.

Marissa Mayer

This article is part of the CodeSmell Series.

Share this