1

I want to design an online book reader system as a programming exercise. I wrote down the following requirements:

  • Searching a book by title.
  • Bookmarking a book.
  • Mark a book as favorite.
  • Give rating.
  • Manage users.

The constraints are that only one user can read a particular book at a time.

I follow Clean architecture. Which advocates that:

  • Defer implementation details like DB and delivery mechanisms.
  • Start with the use case first which guides Interactors / Service Objects.
  • In designing use cases you will come across different Entities.
  • Don't pass objects between boundaries.

I know that question seems too broad hence but I wanted to proper context first, I will proceed from first step. I would like to know to pick up which use case first? Second, should I formulate all Service Objects and then move on to Entities?

  • What have you tried so far? I think you're asking for advice on how to move forward when (in some sense) you haven't really begun yet - I think you may end up with better feedback if you attempt a solution and get stuck and we can collaborate on your design. Also, some decisions you may need to drive; knowing which use case to start with first is likely going to be driven by which one you think is most important - not by a technical reason. – J Trana Oct 18 '15 at 3:14
  • @JTrana if you read my description then you can see I have really done some serious homework. I have prepared the field :) now I need to set the fielders accordingly. Asking for advice from someone experienced one never hurts. Anyways writing code is never that difficult. – vivek Oct 19 '15 at 4:35
2

Learn to model a simple problem into a problem domain model and then into code.

Your first four requirements all relate to books. Your final "Manage users" is vague, so I'll leave that for now.

How do you represent a Book? Assuming each book is unique, you model it with TWO objects. One being a particular book (Book), and the other the set of all books (Library). Library has a list of Book. Book belongs to Library.

Favorite, Bookmark and Rate become methods on Book. After all you should know the rule:- "An action on a real-world object, becomes a method of the object in object-oriented code".

Search becomes a method on the Library object. Add the ability to add, edit and delete book/s in the Library object also.

Create an object that can persist (and search etc) your library to a file, DB or morse code. Create objects that represents human interaction, like a window etc that calls methods on your domain.

Now you have a working system. For now, forget Clean/Service Objects/Interactors/Entities/Boundaries/SomeOtherSilverBullet. They are all rubbish in the way to you producing a simple solution to your problem.

|improve this answer|||||
  • 1
    Actually Favorite, Bookmark and Rate should be a relationship between a book and a user. I don't hope that anyone loses my place in the book I am reading. And I'll be very cross if someone else changes my rating of a book. – Bent Apr 12 '16 at 11:32
-1

Yes start from finding use case then you should find all entities with their relationship and then start building application.

Restriction can be applied by single column value 1or zero, opened or closed respectively in databases table of books against each book

|improve this answer|||||

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.