Then it came the moment to implement some sort of achievement in our web application. I had an idea more or less like the hierarcy described in this question How to implement an achievement system in RoR .
The application we are working on is a software as a service intended to be managed externally without software developers. The thing is it should be possible to create new kinds of achievements runtime by the software administrator via the web interface. The hierarcy then becomes a wall.
I have read somewhere it is possible to implement this situation through finite state machines, but at this time i don't have enough informations about that topic.
Edit: specific question
I thought about modeling an achievement class with a list of conditions to be met. This basic class Achievement would have a boolean which recursively checks all the conditions to be valid. The conditions then could be hardcoded classes. The system admin then creates new kind of achievements with combinations of the atomic conditions.
My fear is the growing number of classes for the atomic conditions. I dont want to have 30+ condition classes in the project. Any advise is really appreciated.
Edit: more details about the implementation
From SpyrosP response, it seems a good idea to build the described DSL. In some way achievements then must be saved in the database. Keeping the same example:
comments :less_than => 10
check_comments
comments :more_or_equal => 100
award_hundred_comments_badge
In order to dinamically create achievements there should be a table that stores the condition(s) to be checked:
Achievement
| id | name |
| 1 | "Houndred Comments" |
Condition
| achievement_id | expression |
| 1 | some sort of condition |