Design question (use the same instance or copy?)

We are developing an e-learning website where you can practice LearnItems (typically words of a foreign language). The concept is very similar to Memrise.

When a user practices a LearnItem, a Result object is created (it contains the date of the answer, plus a flag to indicate if the answer given by the user was correct)

The LearnItems are grouped into LearnItemLists, and a user can choose to create his/her own LearnItemList, or use an existing one (e.g. LearnItemList “The 1000 most common english words”, which has 1000 LearnItems)

This is where we have differing opinions in the team.
When a user wants to use an existing LearnItemList, created by someone else, then

Version A:

We store the same LearnItemList instance for every user that subscribed to the same LearnItemList.
This means that we have to store the results for each User+LearnItem in a separate structure, since a LearnItem belongs to several users.

Version B:

Deep copy all LearnItemLists.

We copy the LearnItemList with all its LearnItems to each user that subscribed. This way we can store the Results for the LearnItem for the given user simply by referencing User.LearnItemList.LearnItem.Results

Both versions have pros and cons, but in general, which one makes more sense?

9

I would store single instances of learn items bit have learnItemLists per user.

Ie

LearnItem
{
    String Id
    ....
}

User
{
    LearnItemList[] LearnItemLists
}

LearnItemList
{
    UserId
    Name
    String[] LearnItemIds
}

The key thing for me is that the user can make their own lists and presumably edit them.

Therefor if I want to use an existing list I will need to make my own copy of it.

I dont need my own copies of the learnItems themselves though, just the Id, as these are the same for all users

1

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *