© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4w ago•
11 replies
lukepuke123

Design choice for optional hook subscription

beginner
At some manager class there is:

AbstractType[]

where AbstractType has the empty override method OnTick()

30 times per second, the manager class wants to call OnTick for all of the instances in that array but if it does it over the original list then there are wasted calls for non-overriders.

So i want the AbstractType implementers to be able to indicate that they implement OnTick with the caveat that I really don't want to clutter the API for the implementers.

I've narrowed it down to two options:

1. have the default throw a NonImplementedException, have the manager iterate the list, and catch / subscribe accordingly on start. Then use the subscriber list to do more efficient calls.
2. instead of throwing and catching on start, use reflection to check if they implement the method.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Best architectural design choice?
C#CC# / help
3y ago
Plan/design for app game
C#CC# / help
3y ago
❔ best design practice for this?
C#CC# / help
4y ago
Design
C#CC# / help
7mo ago