-3

I have an object with a method that should be called by user code when long pressing on a map. The same object also has event handlers that it uses to tell its users that an event occurred.

I have prefixed the names of the event handlers with on, e.g. onDrawingComplete, as is a common naming convention for event handlers.

But I'm not sure what the standard naming convention is for the opposite case - methods that should be called by user code to tell an object that an external event occurred. For now, I have used the prefix handle, e.g. handleMapLongPress.

Here's some pseudo code to illustrate:

MyClass{
   Function onDrawingComplete; 
   void handleMapLongPress(LatLng coordinates);
}

myInstance = new MyClass();
myInstance.onDrawingComplete = (){
  // Do something in response to a drawing being completed
}

myMap = new Map();
myMap.onLongPress = (coordinates){
  // Tell myInstance that there was a longpress at [coordinates]
  myInstance.handleMapLongPress(coordinates);
}

Is there a standard naming convention for the kind of method that should be called by user code to let an object know about an event that occurred somewhere outside it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.