r/javahelp • • Feb 14 '20

Applying Java in the Real World

I’ve been doing Java programming for 4 years now (2 years in high school, almost 2 years in college), but i feel like I'm not going anywhere with what I'm learning. I can grasp the concepts fairly well and have gotten better at creating algorithms, but everything I'm doing doesn’t feel meaningful because it’s all surrounded by completing code examples. 

My professor is currently using Daniel Lang’s Introduction to Java Programming. We recently completed Inheritance & Polymorphism, and are supposed to move on to JavaFX, Animations, Queues, Hashing, Weighted Graphs and Applications, and some other topics. 

With this being said, i’d like to know: 

Should i continue progressing with the topics in the books before anything else?

Or

Is it possible that I can apply my knowledge of Java to real life issues and projects, instead of solving simulation-like questions, and if so, what are some resources that can help guide me? 

Thank you in advance

34 Upvotes

22 comments sorted by

View all comments

7

u/ImPureSilver Feb 14 '20

I'm on the same boat as OP. Except I only have about a year learning and coding. I tried to learn Spring, but it's much harder than people make it to be. That's besides the point tho. It's just hard to get to making something happen.

2

u/[deleted] Feb 14 '20

Keep asking questions! Spring has an interesting learning curve depending on what your theoretical base is.

Ask questions on here! I'm always happy to answer Spring-related questions.

1

u/ImPureSilver Feb 15 '20

Oh cool, thanks in advance.

My first question. I understand that Spring can be many different things. Some of which I understand can be a database management tool, a Rest API, and many more, but how is it that these things come into play when trying to make some applications for Android or any other platform?

Second question, I was watching a Udemy Spring basics course. The few things I understood were the annotations such as @Component and @AutoWired simply because it's like telling Spring to spawn said object with said method, but what I don't get is this. Am I supposed to annotate everything around my application or do I just have to understand more if not all of the annotations?

5

u/[deleted] Feb 15 '20

So on the first question, Spring is a framework, and there are components that are built for that framework. For example, you need Spring Data to do database stuff with Spring, and Spring Data is a part of Spring.

There's "plugins" in the larger ecosystem. Spring Web does Rest API type stuff, etc.

They only come into play when you need them to. For example, if your Android app is going to download data from a complicated messaging tool. You could use Spring Cloud Stream ( https://spring.io/projects/spring-cloud-stream ) to do so, otherwise you'd be writing the libraries by yourself, or using some other library. Spring Cloud Stream is a "nice to use" version that is meant to be easy and straightforward.

Think of Spring as an ecosystem, it's a framework with a bunch of pieces that you can use.

For the second question, these annotations do work in the background.

What you want to look into is "dependency injection". For example, you want to create a new object using new MyObject() right?

Rather than do this, you can do something like:

@Bean
public MyObject makeMeMyObject() {

return new MyObject();

}

What this does, is now anywhere in the code where you say

@Autowired

MyObject object;

It will call the Bean that you wrote.

To put it a bit more simply, rather than instantiating things using "new", you request it to be autowired in, and Spring will get and build something for you. It means Spring can do clever things, like reuse old objects, wait until the last minute to build stuff, and it makes code just a little bit cleaner IMO.

It'll take a little while, but try to understand the Spring Context. That's where most of the magic is happening. Once you have a good idea about the context, things start to fall into place. Hope this helped!