I am working on a problem and struggling for the best design.
The problem is:
Feature: counting votes
I want to see the counts for candidates within a given time frame
So that I can announce the winner of the competition
Scenario: partition choices sent to the queue by candidate percentage
Given 10000000 votes were received
And votes were distributed against candidates as:
| candidate | percentage |
| candidate-1 | 5 |
| candidate-2 | 10 |
| candidate-3 | 20 |
| candidate-4 | 25 |
| candidate-5 | 40 |
And no more than 3 votes per user are allowed
When CountMeUp is asked for the results
Then it responds in under 1 seconds
And the final counts are:
| candidate | count |
| candidate-1 | 500000 |
| candidate-2 | 1000000 |
| candidate-3 | 2000000 |
| candidate-4 | 2000000 |
| candidate-5 | 3000000 |
The given scenario implements the following acceptance criteria:
• Count Me Up should be accurate. So if there is a total count of 100 votes and 60% are given to candidate-1 then Count Me Up should return 60 as the count of votes for candidate-1.
• The same user can vote multiple times, up to a maximum of 3 times for the same candidate or for different ones. Count Me Up should not count a vote if the same user already exceeded the maximum allowed number of votes (that is should not count user-1 vote for candidate-5 if user-1 already voted for candidate-1, candidate-2 and candidate-3). This is the reason why candidate-5 for example received "only" 3M votes instead of 4M. –
• Count Me Up should be fast. Count Me Up will be used as a close to real-time tool to constantly show the results of the competition, so it should be invoked every second or so to show progress. It follows that it should respond in less than 1 second. -
I am only looking for the design. I want to know what is the best possible way to design this problem in c#.
Aucun commentaire:
Enregistrer un commentaire