-6

Description

Its a follow up question of writing use cases.

Taking from nouns defined in my user story and requirement I found the following candidates to be classes:

  1. User
  2. Question
  3. Session
  4. Attempt/UserAnswer
  5. Score
  6. Category/Topic
  7. Hint

I think the following relationship holds between these objects:

  • User (o2m) Session
  • User (o2m) Attempts
  • User (m2m) Question
  • Question (m2o) Category
  • Question (m2m) Attempt
  • Question (o2m) Hint
  • Attempt (o2o) Score
  • Session (m2m) Question

Questions

  1. Do I need to declare collection type for each objects like Users, Questions, Sessions and Attempts?

  2. How to identify the object relationship between class of objects defined above? and who is the owner of the relationship?

  3. Is it a good idea to find behaviours after finding object relationships?

  4. Am I on the correct level of abstraction? or missing any class?

closed as too broad by amon, Greg Burghardt, Bart van Ingen Schenau, Jörg W Mittag, Thomas Owens Dec 6 '17 at 11:58

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • I don’t know your domain but I would get rid of the User m2m Question relationship and rely on the User o2m Attempt relationship to transitively get the Questions that a User had answered. I would even consider going a step further and removing the User o2m Attempts and then relate the Attempts to the Session, and transitively obtain the User’s Attempts via the Sessions. I’d be very curious to learn what Framework is being used if any and how this object model is persisted if it is at all. – RibaldEddie Nov 29 '17 at 7:19
  • From your first post about use cases, you’ll notice that a user must start a session to be shown questions to attempt. So my comment is about ensuring that it’s not possible to associate a user to an attempt or question without the session. – RibaldEddie Nov 29 '17 at 7:22
  • @DocBrown strange! I posted my query on meta and was asked to first tell my findings or efforts before asking questions, I just did that. I am not here to trick anyone, its not some scam site. – CodeYogi Nov 29 '17 at 9:05
  • @RibaldEddie I am not using any framework right now, I am learning to write entities or domain object which are framework or business logic agnostic. – CodeYogi Nov 29 '17 at 9:18
  • 1
    @CodeYogi: ok, I rewrote my answer and undeleted it. – Doc Brown Nov 29 '17 at 9:57
2
  • ad 1: not if your programming language provides you with generic collections you can use for any of your classes

  • ad 2: you analyse your use case description and see how those objects are related. It seems you did this already, so do you really have a question here? "Ownership" is not important at that level of abstraction, you should not worry about it before you start implement some use cases in code. Then it is early enough to decide if, for example, a User needs a collection of Sessions, or each Session needs a reference to its User, or both.

  • ad 3: it is IMHO better idea to start soon with some coding and implement a first small feature or spike, then you will find out which behaviours your objects need.

  • ad 4: after your final edit, your list seems pretty complete. But this is an example invented by yourself, so only you know if it is complete "enough".

As a general recommendation: do not overanalyse this case, better start getting into the cycle "analyse a little - implement a little - test a little - refactor". This brings you likely much more feedback about your design than anything we can tell you here.

  • I did exactly here but hardly got any response. Is there is something wrong in the question? – CodeYogi Nov 28 '17 at 14:01
  • @CodeYogi: if you really want to know, ask on meta. That other question, however, was IMHO broader and more vague than this one. I think both questions have the issue to be very specific to your artificial exercise, and I personally prefer to deal with real-world software engineering problems; some of the problems you have are probably caused by the fact it is an invented problem, if it would be a real world problem, you would have a clearer goal what to achieve. – Doc Brown Nov 28 '17 at 14:28
  • Yes, they are invented because in general actual problems are too large or too complex to ask here. I try to make problem simpler by mapping them to some practical yet simpler version. The questions I ask maybe broad but they are real and ask for expert advice. It depends how you see it, you can think that the question is in fact a real project. – CodeYogi Nov 28 '17 at 14:46
  • Also, these examples are may way of showing that I am really interested in the topic and have done some work rather than shooting in the dark. – CodeYogi Nov 28 '17 at 14:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.