I've run into a common annoyance where I'll have an event that sends a parameter, but some consumers of the event don't need the parameter at all. So I wrap it in another function that decouples the signature from the actual method call. This adds one more level of thought that a reader needs to parse before understanding the code.
void OnEnable() {
HeightSnapEvents.OnSnapToHeight += PictureMightHaveMoved; //event has float parameter
}
void PictureMightHaveMoved(float height) {
AlignWithPictureTaking(); //don't need height at all.
}
void AlignWithPictureTaking() {
Debug.Log("Aligned!");
}
I've also tried:
void PictureMightHaveMoved(float unused) {
Debug.Log("Aligned!");
}
I've also considered having the event also call a parameter-less version of itself, but then it adds complexity making sure all the events are fired properly.
Is there a more elegant solution that keeps readability?
Details: I'm programming in c# and Unity, but this shouldn't really matter.