• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

BookRentals - Spring Boot - code review  RSS feed

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I would like to hear some opinions from your side. I would like to present book rentals which contains:
- managing accounts (CRUD)
- managing books (CRUD)
- 4 options of finding books + finding the latest 3 books
- renting/returning books with many security features
- penalty system - 1 minute is free, next minutes are paid. 1min = 1$

I will paste here link to GH, because project has too many classes to put them all here. If necessary, I can paste some classes to if there is problem with a link. : https://github.com/must1/BookRental
 
author & internet detective
Posts: 39129
723
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a lot of code. Is there any class in particular you are curious about?
 
must Janik
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:That's a lot of code. Is there any class in particular you are curious about?



Yea, that's why I did not paste it here.
I'm curious about test,  if it is properly written or not.  Same for logic (service for penalty, returning and renting books). I also want to ask about structure of the project. Is it good?
 
Sheriff
Posts: 5672
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not going to be a lot of help since the last time I used Spring was five years ago, but I can help in other ways.

Installed
The project installed from Maven without any problems.  That's always a good sign.

Structure
The structure of the project definitely need a model package.  I would put all of your "things" in there, like Book.java and Account.java.  (It doesn't have to be a concrete thing.)  Move all your controllers into the controller package.  I don't think packages like "book" and "account" are a good idea.

There is some controversy about where to put your "business logic."  In model is one idea; in controller is another.  I wouldn't mind a logic package but I don't know how accepted that is.

Programming
Your code is clean and well-formatted.  It does need documentation, though.

I noticed that you're using longs for currency.  This is a good alternative to BigDecimal if you're carrying cents in the amounts.  An int is probably sufficient, for future reference.

Well, that's about all for now.  
 
must Janik
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, My structure before was: model, controller, service, repository. I was told to make it this way, to group thematically, so I do not know now.
Do you think you would add something?

Thanks for the answer!
 
Sheriff
Posts: 12966
217
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Re structure, there are a number of schools of thought around this. Some structure along application architecture lines like model, controller, persistence, etc.

Lately, I've been influenced by Uncle Bob Martin who asserts that like physical architecture, it should be apparent from the project root level what kind of application you're dealing with. For example, if you see a church or an office building, you can usually easily tell which one is which because of what you see on the outside. Similarly, what you see at the project root level should inform you immediately of what kind of application you're dealing with. When you structure around model, controller, persistence, then an accounting application will be indistinguishable from a library application or any other application that follows this convention. You have to dig into the model directory before you get an inkling of what you're dealing with.

On the other hand, when you have domain-level concepts at the root of the project structure, then you can immediately tell that you're dealing with some kind of book rental application.
 
Junilu Lacar
Sheriff
Posts: 12966
217
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually lean toward splitting along architectural lines at the deployment artifact level. I rather like the approach of a myapp-core.jar having all the domain classes and infrastructure interfaces. Then other jar files like myapp-persist-ora.jar for implementations of the DAO interfaces defined in core. If I have a different set of implementations, for example, I just have to provide them in something like myapp-persist-mysql.jar. This approach adheres to SOLID design principles, too.
 
must Janik
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do not get it fully. So should I keep like that (grouping thematically) or make model, controller, persistence, etc. ?
Could you give me example of my structure? I mean, no every class, just a few:
Blabla/
Papa.class, papa2.class
Blabla2/
Papa3.class,papa4.class
 
must Janik
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really care about this. Can I get an answer?
 
Knute Snortum
Sheriff
Posts: 5672
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is "an answer", I think it's a matter of opinion and style.  I didn't know about thematic grouping, probably because I've been out of the programming business for about five years.  Maybe it's the "new thing."

I think what is important is that you pick a style and keep using it throughout your project.  Since you've moved to thematic grouping, I'd stay there.  Just be aware on your next project that there are other choices.  Choose what's best for you.
 
Junilu Lacar
Sheriff
Posts: 12966
217
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute is right. Nobody can answer this for you; you have to make a choice and stay consistent with it.
 
must Janik
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To bo honest, I will the most with MVC + repositories foramt. But a lot of guys say, it is not the best solution for it.

To sum up, the way I did right now is good or schould I should something?
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!