Passion of IT

Design Book object in Amazon Website

How it should be designed a book object in the Amazon website?

Should it have a logic?

if I were the architect of the system I wouldn’t have put any logic in that book object so it should be just a container and below are my reasons

  1. The clean code says that one class should be as short as possible with just one responsibility. the less methods and the less code is inside the better it is.
  2. I imagine the Amazon web site made of the Model View Control pattern and SQL database using the DAO pattern. If that’s implemented using also Spring and the Dependency injenction pattern and Hibernate the system should be designed as below
    1. View: normal HTML  Javascript page so when the user wants to see the list of the book it calls the REST endpoint in the Spring book controller called getBook
    2. Controller: Spring Book controller with the initial business logic for verifying the input of the user, calling the model, populating a response object which contains a list of books and returns it to the view
      1. All logic should be in the controller and its method getBooks, the book should contain just informations
    3. Model: Another REST endpoint which like the controller has the logic. The logic is inside the rest book service and the book object should be just a container.
      1. That rest service can collect the information from the SQL database using hibernate and as usual the Hibernate book object is just a mapping of the book table, all logic should be inside the BookDAO using the DAO design pattern

For me the book should be just a bean POJO with private variables, getters, setters and constructors

The more logic you put inside the less clean is the code

 

No Comments Yet

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite="
"> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Comments

Michele Rizzithe website doesn't exist. Ara you a robot? In any case it's difficult that an automatic system writes a comment here since there are two captchas...
Hello there! This is kind of off topic but I need some guidance from an established blog. Is it very hard to set up your own blog? I'm not very t...
We are a group of volunteers and opening a new scheme in our community. Your web site offered us with valuable information to work on. You've done a...
March 2024
M T W T F S S
« Dec    
 123
45678910
11121314151617
18192021222324
25262728293031

Login