3

While writing personal projects as well as well in the job, I often struggle to proceed on the current task because either I get stuck on what I was thinking or didn't thought about all the corner cases that may arise in the future. I was thinking what if before coding anything I do some brain storming and write a series of steps as I do in algorithm problems.

I know its known as 'Use cases' but I think I will get really side tracked if I start to read all the books on it, I want something simple yet robust for at least my personal project. I did some homework and while writing a simple toy project I though to write an use case which is basically how the user would interact with the system.

Here it is:

"""
Design a question and answer system which allows
user to see optional hints to each question and
let him assign score to each question answered.

The order of the question next time would depend
on the current scores.

UseCase:

1. User sees a welcome message and avalilable topics
2. User chooses the topic
3. A new session is started for the user
4. User sees a question on the selected topic
  4.1 User asks for hint by pressing '/h'
  4.2 User sees a hint
    4.2.1 User presses '/h', Repeat step 4.2
    4.2.2 User presses 'return' GOTO step 5
5. User is prompted to answer the question
6. User answers the question, presses 'return'
7. User sees the answer
8. User is prompted to give a score [1, 3]
7. Repeat steps 4-8 until there are no more questions
8. User sees the summary of questions and scores
9. User is asked if it needs to start another session
  9.1 User enters 'Y', Repeat steps 1-9
  9.2 User receives a goodbye message
10. End  

Requirements:

1. The user can choose topic
2. An user can see all its previous sessions
3. The user can stop and resume a session
4. The system should be designed in such a way that
   the order of the questions changes based on the
   user's last score for each question

"""

I need to know if there is are irrelevant/redundant details which can be avoided and if there is any details which can be added?

Is this correct approach of solving problems in general?

I am planning to read more about use case design via standard books on the topic but I think its a good strategy to learn something new before diving into details.

  • Those aren't use cases. A use case is something like: "As a user, I want to choose the topic so that I can get questions that are related to my chosen topic." – Robert Harvey Nov 7 '17 at 19:10
  • 1
    Use cases are very simple to make; just fill in the blanks: "As a _____ I want to _____ so that _____" – Robert Harvey Nov 7 '17 at 19:12
  • @RobertHarvey if not use case, are they user stories? I think it helps me understanding requirement clearly, should I replace them with use case? which is more effective? Again, the main criteria is short and effective. – CodeYogi Nov 7 '17 at 21:12
  • 1
    Ah, right, sorry. User story != use case – Robert Harvey Nov 7 '17 at 21:13
  • @RobertHarvey lets not dive in details of the terms, I need something which is useful for gather my thoughts and details from programmer point of view. – CodeYogi Nov 10 '17 at 7:14
2

I need to know if there is are irrelevant/redundant details which can be avoided and if there is any details which can be added?

Probably nothing redundant, did not catch anything at a first glance. If these things are all relevant, or if things are missing is up to the what a "domain expert" or "user" or any other stakeholder of such a system might think about it (but since it is your toy project, this is simply up to you).

To make this more clear: I can imagine other features like moving backward to former answers to correct them afterwards, but if you need or want them (or not), you have to decide by yourself. I can also imagine of leaving some things out for a minimal version of the program (like the "hint" or "scoring" features), but you need to decide by yourself if the purpose of this description is to give a full list of potential features, or a partially list, or a minimal list.

Is this correct approach of solving problems in general?

Sure, the "process of breaking a complex topic or substance into smaller parts in order to gain a better understanding of it" has a well known name, it is called "Analysis", see Wikipedia. I am sure you have heard that term before.

In 2000, Joel Spolsky wrote some short blog entries about how to create "painless functional specs" for software development, start here or here, those example will probably be more helpful than anything I can tell you here in a short answer.

  • I wanted to say of given an objective then, did I covered everything? where I should be more careful? – CodeYogi Nov 7 '17 at 13:56
  • @CodeYogi: see my edit. – Doc Brown Nov 7 '17 at 14:15
  • So, I read the link you posted. Frankly speaking the author started with a very promising note but at the end it was nothing but a flop show, I couldn't find anything useful in his "function spec" but he mentioned how to deal in a corporate world. I find mine version more helpful while writing a new feature. Instead I found one article with a lot better example fullstackmark.com/post/11/… – CodeYogi Nov 10 '17 at 7:20
1

I want to note one approach to use cases.

First, try to identify object candidates in your domain. Then think of their responsibilities, just to refine them, to understand what objects you really need. Then draw a semantic net with intrinsic relations between object. Then take a couple of objects and see what services do they add up to overall project value. Think of use cases they might take part in. Write them down.

And just in case, two classic books: Writing Effective Use Cases by Alistair Cockburn and User Stories Applied: For Agile Software Development by Mike Cohn.


Update: there is a very relevant example I decomposed just in an adjacent question. The main point is the one noted by Christophe in a comment: start with understanding your domain first.

  • 1
    That's an interesting approach: to complement the use case analysis by surfing through the domain model abd anticipate unexpressed requirement. I can only confirm that this is very effective in practice. However it supposes that there is a reliable domain model, and i'm afraid OP doesn't have one as he's struggling to structure more his approach. Little suggestion: list the full titles of the book in your answer (it's not obvious that there are two different links currently anyway). – Christophe Nov 7 '17 at 18:58
  • Agreed. Fixed my answer. – Zapadlo Nov 7 '17 at 19:25
  • @Christophe "i'm afraid OP doesn't have one as he's struggling to structure more his approach" what I am missing, your suggestion can be invaluable. – CodeYogi Nov 7 '17 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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