I’ve given some thought to implementing badges (just like the badges here on Stack Overflow) and think it would be difficult without Windows services, but I’d like to avoid that if possible.
I came up with a plan to implement some examples:
- Audobiographer: Check if all fields in the profile is filled out.
- Commentor: When making a comment check if the number of comments equal 10, if so award the badge.
- Good Answer: When voting up check to see if vote score is 25 or higher.
How could this be implemented in the database? Or would another way be better?
A similar-to-Stackoverflow implementation is actually a lot simpler than you have described, based on bits of info dropped by the team every once in awhile.
In the database, you simply store a collection of
BadgeID–UserIDpairs to track who has what (and a count or a rowID to allow multiple awards for some badges).In the application, there is a worker object for each badge type. The object is in cache, and when the cache expires, the worker runs its own logic for determining who should get the badge and making the updates, and then it re-inserts itself into the cache:
And a concrete implementation: