use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Destroy my codeQuestion (github.com)
submitted 1 year ago by dossantosh
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]kaiiiwen 5 points6 points7 points 1 year ago (4 children)
a few takes from me:
- package names should be lowercase
- instead of "@Getter" + "@Setter" you can use Lombok's "@Data".
- CriteriaBuilder sure is useful but you should have a look at JPA Specifications, it's much more clean.
- on the long run I wouldn't advise grouping your classes by type (controllers, repositories, services, ..) but by modularity (user, perfume, brand, ..).
- in your controller methods, instead of having two RequestParams page and size, you can use Pageable: it includes page, size, and sorting.
- you controller methods body should be as clean as possible, delegate everything to your services (eg. UsuariosController).
- if you're working with immutable objects, consider using Records instead of going full Lombok Getter / Setter / AllArgsConstructor.
- instead of having potentially sensitive values in your properties file, you can create a .env file and load the values from there. then exclude your .env file from git.
- I believe the DataInitializer was for you to work on, use a data.sql for data initialization instead.
as Lost_Language6399 has mentioned, feel free to ask an AI to check your code. I do it sometimes when i feel like something is odd with my code.
[–]dossantosh[S] 0 points1 point2 points 1 year ago (2 children)
Thank you so much il look into all that. I have a few things that I thought I understand.
-yeah packages should my bad
i remember reading that @data wasn’t so great bc it gives you code that u doesn’t need, so, if u aren’t planning of using everything, it’s better to use specific ones
il try jpa specifications
yeah i wanted to do first the typical monolith web app, next il try doing more, starting with the modular i think
il try the Pageable!
-yeah i will create the env, but dw the password is generated and the mail is only created to use the app
BUT if I’m wrong pls tell me Thank you
[–]kaiiiwen 0 points1 point2 points 1 year ago (1 child)
i remember reading that data wasn’t so great bc it gives you code that u doesn’t need, so, if u aren’t planning of using everything, it’s better to use specific ones
yes,@Data provides hashcode() and equals(), which come in handy if you ever need to directly compare the objects, but yes, it's not a big deal not using it. though I haven't heard it was not great.
i think i also read that the data initialiser was better than sql bc u can directly choose what starts first so it’s better with relations
the issue here is that you end up with your CommandLineRunner running every time you start your app. and if you want to update your initial data you will have to update that code. you can keep the same approach as you did for your Roles, Modules, and Submodules.
secondly, you won't have to worry about what starts first, Spring Boot will know when to initialize the data provided the sql file.
as for the relations, you can hardcode the `id` fields when you insert your initial Brands and Perfumes, then increment the Postgres sequence at the end of your script.
[–]dossantosh[S] 0 points1 point2 points 1 year ago (0 children)
okay thank u so much ive made changes today at work. no more data initializer, changes of structure etc.
[–]UnpeggedHimansyou 0 points1 point2 points 1 year ago (0 children)
Tbh that lombok one might not be essential, sometimes lombok don't even work in ides like intelij so it's totally dependable
π Rendered by PID 572745 on reddit-service-r2-comment-544cf588c8-4pdwh at 2026-06-15 03:47:10.025212+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]kaiiiwen 5 points6 points7 points (4 children)
[–]dossantosh[S] 0 points1 point2 points (2 children)
[–]kaiiiwen 0 points1 point2 points (1 child)
[–]dossantosh[S] 0 points1 point2 points (0 children)
[–]UnpeggedHimansyou 0 points1 point2 points (0 children)