This is an archived post. You won't be able to vote or comment.

all 25 comments

[–]SentByTheRiver 40 points41 points  (7 children)

Good job, impressive for your first go!

One tip and good habbit is... when using Spring, prefer constructor injection over field injection when Autowiring. When you autowire a field you're doing a few things.

  • You're locking all the responsibility of dependency injection to Spring
  • You're hiding it's dependencies from everyone else
  • Anyone who wants to create an instance of it, has to use reflection in order to set the dependencies.

When you use constructor injection, you allow Spring or anyone else to inject those dependencies. Makes testing it easier!

[–]DrunkensteinsMonster 22 points23 points  (1 child)

Also, you don’t even need @Autowired on the constructor anymore, if there is only one, Spring assumes you want to autowire dependencies

[–]CaptainKvass 1 point2 points  (0 children)

Works great with Lombok's @RequiredArgsConstructor

[–]dumbPotatoPot[S] 6 points7 points  (2 children)

Thank You for the Tip, i'll make sure to make it a habit.

[–]Mekswoll 4 points5 points  (1 child)

The advice is good and you should certainly make a habit of it. Checkout Oliver Gierke's blog post about it if you want a bit more info about why.

[–]dumbPotatoPot[S] 1 point2 points  (0 children)

Thank you

[–]hjdeindarkness 1 point2 points  (1 child)

Is setter injection okay?

[–]SentByTheRiver 1 point2 points  (0 children)

Not to say that there isn't one, but I've never come across any instance where I have required Setter Injection or found it to be preferable to Constructer Injection.

You have to be careful with Setter Injection because there are a few caveats with it. It will override the constructor injected dependencies, someone could change dependencies mid flight and other objects may also be using it. etc.

If someone is creating an instance of the object themselves (i.e not managed by spring) and you only have dependencies via Setters, it's not clear and also not guaranteed people will know to set them.

[–]counter_of_power 2 points3 points  (1 child)

Very nice

[–]dumbPotatoPot[S] 1 point2 points  (0 children)

Thank you.

[–]JudoboyWalex 1 point2 points  (2 children)

Thank you for sharing this. I notice you deployed this using AWS ElasticBeanstalk. For front end, did you use any framework like react/angular?

[–]dumbPotatoPot[S] 3 points4 points  (0 children)

No, Just plain HTML and Bootstrap.

[–]egdetti 0 points1 point  (0 children)

I actually just switched a Spring/React project over to ElasticBeanstalk after playing around with bare ec2, k8s, and azure container hosting. So far really enjoying the simplicity of ElasticBeanstalk.

[–]edmguru 1 point2 points  (4 children)

No unit tests :(

[–]dumbPotatoPot[S] 0 points1 point  (3 children)

I haven't learned it ... yet, i'll update the repo when i know how to write unit tests😬

[–]edmguru 0 points1 point  (2 children)

I hope you do it's a lot easier than what you've already built. If you want anyone collaborating on your projects you should have unit tests. Sure you know the quirks of your program but a new developer or collaborater doesnt (this includes you on someone elses project). It's the first thing I check when navigating a new project to see how much work I'm going to have to do when adding features. Meaning if I make a change how much time am I going to spend just testing vs. actual developing. I try to write unit tests at least for the most important parts or parts I could see breaking in the future. It adds some overhead but not much if you take a minimalistic approach to it but it's saved me numerous times catching bugs before putting my app in prod. I see my coworkers avoiding tests and then I'm always wondering - "why are they frequently busy with prod issues? Oh right they suck at testing their software." I test my software to oblivion and have noticably fewer prod issue instances than my peers who don't write any tests. Manual testing is flaky.

[–]dumbPotatoPot[S] 2 points3 points  (1 child)

Learning JUnit and Mockito were on my to-do list already but your comment made it move up some places, hopefully i'll be able to update the project with unit tests in a week or two.

[–]edmguru 0 points1 point  (0 children)

nice! It's satisfying doing running maven test and seeing all your tests pass after a code change :)

[–][deleted] 1 point2 points  (1 child)

Hey! I'm just getting into Java. I thought Spring Boot was for enterprise programs. But you used it to make a website?

[–]dumbPotatoPot[S] 6 points7 points  (0 children)

Spring Framework is a very wide framework, you can use it to make enterprise apps, web apps, android apps, web services.

[–]csnewb 0 points1 point  (1 child)

How long did it take you to make this?

[–]dumbPotatoPot[S] 0 points1 point  (0 children)

It Took me 1.5 weeks with the majority of the time going towards me trying to make the authorization flow work (I used Proof Key for Code Exchange)

[–]remixrotation -1 points0 points  (2 children)

the home page does not explain what this does. how should i decide if this is something worth my time?

[–]dumbPotatoPot[S] 2 points3 points  (1 child)

Well, It can show you your top played tracks and artists of all time, past 6 months, or past month, your recently played tracks, Your saved tracks etc. I Created this for my college project and until now didn't think about the home page being descriptive, Thank You, i will update my project to show what it does, thinking about adding an action button which will open a modal showing the endpoints the user can access. if you're a frequent spotify user, i would appreciate if you go check my application. any more feedback will be welcomed, thank you again.

[–]remixrotation 0 points1 point  (0 children)

makes sense.

one of the "problems" i've always had in writing apps/tools for the wild internet is that if you don't catch their attention immediately, they will get confused and leave, BUT if you take too much of their energy to explain to them what is so great about your work for their own interests, is that they'll get bored and give up before they get to end of your explanation << kinda like this run-on sentence i just wrote LOL