This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi All! This is my first post. I apologize ahead of time if this post has any problems (length, format, etc.)
I am trying to design software to generate draws for a badminton tournament and wanted some help (comments/feedback) making design choices. Each player's information is stored inside of a comma delimited text file that I parse inside of the software (just a Java program for now; would like to integrate it into a GUI). The goal of the software is take all the information and construct 20 draws for 20 events, where each draw gives information on who plays who.
The basic structure I have set up so far:
-CompetingEntity Abstract Class: extended by Participant and Team Classes. (A team consists of two participants)
-Event Class: represents a particular event flight. (There are 4 flights : A B C D. 5 event types: mens singles, mens doubles, womens singles, womens doubles, and mixed doubles. 20 total events)
-All participants are stored inside of a HashMap, and events in a separate HashMap. Each participant stores a String denoting the events he/she is in, and each event stores a list of participants.
-Match Class: represents two competing entities that must play each other.
-Miscellaneous: when parsing the txt file, there are participants whose partners cannot be matched up (either missing partner names and/or spelling inconsistencies). I used two linkedHashSets to store
a needPartnersList and a mismatchedPartnersList
1. I know I haven't given enough information, but thoughts on my choices for data structures so far? (efficiency, memory allocation, simplicity, etc.)
2. What type of data structure should I use for a draw, and how should I go about implementing the logic? (My thoughts: some type of tree structure seems most natural.)
Zhong Chihwei wrote:Each participant stores a String denoting the events he/she is in, and each event stores a list of participants.
I know nothing about tournament planning, so I'm afraid I can't help with your specific questions. However I would suggest that you consider using an enum for this purpose instead of a String. I avoid using Strings this way because they are inflexible and kind of a pain to work with.
Joined: Jun 19, 2012
Thanks Dennis! That crossed my mind too; I'm still kind of a noob with enums. o.o
I tried implementing a sorted tree structure and ended up with an ugly problem. Here's an example:
"For D men's doubles, lets say there are 20 teams. That means that I will need 19 matches to determine a winner. To create matches, I first calculate that I need 10 starting matches, and then 9 more matches with yet-to-be determined competitors to eventually crown a winner. Each of these 19 matches that I create has it assigned a unique match number equal to the static numMatchesCreated value and then subsequently added to a sorted tree structure."
However, when I insert each of these matches in one at a time into the tree, the tree degenerates into an array with the root being 19 and the bottommost leaf being 1.
1. Should I even use a sorted tree structure? (My cs knowledge is a bit limited, but I think the sorted tree algorithm is a heap, and I'm not sure if that's what I want)
2. If so, is there any way to sort it by breadth instead of in a heap manner?
3. Is there any way to balance it?